66use ChrisWhite \B2 \Exceptions \BadJsonException ;
77use ChrisWhite \B2 \Exceptions \BadValueException ;
88use ChrisWhite \B2 \Exceptions \BucketAlreadyExistsException ;
9- use ChrisWhite \B2 \Exceptions \NotFoundException ;
10- use ChrisWhite \B2 \Exceptions \FileNotPresentException ;
119use ChrisWhite \B2 \Exceptions \BucketNotEmptyException ;
10+ use ChrisWhite \B2 \Exceptions \FileNotPresentException ;
11+ use ChrisWhite \B2 \Exceptions \NotFoundException ;
1212use GuzzleHttp \Psr7 \Response ;
1313
1414class ErrorHandler
1515{
1616 protected static $ mappings = [
17- 'bad_json ' => BadJsonException::class,
18- 'bad_value ' => BadValueException::class,
19- 'duplicate_bucket_name ' => BucketAlreadyExistsException::class,
20- 'not_found ' => NotFoundException::class,
21- 'file_not_present ' => FileNotPresentException::class,
22- 'cannot_delete_non_empty_bucket ' => BucketNotEmptyException::class
17+ 'bad_json ' => BadJsonException::class,
18+ 'bad_value ' => BadValueException::class,
19+ 'duplicate_bucket_name ' => BucketAlreadyExistsException::class,
20+ 'not_found ' => NotFoundException::class,
21+ 'file_not_present ' => FileNotPresentException::class,
22+ 'cannot_delete_non_empty_bucket ' => BucketNotEmptyException::class,
2323 ];
2424
2525 public static function handleErrorResponse (Response $ response )
@@ -33,6 +33,6 @@ public static function handleErrorResponse(Response $response)
3333 $ exceptionClass = B2Exception::class;
3434 }
3535
36- throw new $ exceptionClass ('Received error from B2: ' . $ responseJson ['message ' ]);
36+ throw new $ exceptionClass (sprintf ( 'Received error from B2: %s. Code: %s ' , $ responseJson ['message ' ], $ responseJson [ ' code ' ]) );
3737 }
3838}
0 commit comments