Skip to content

Commit 6703cf6

Browse files
committed
beautify error handler
1 parent ca1b92c commit 6703cf6

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/ErrorHandler.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
use ChrisWhite\B2\Exceptions\BadJsonException;
77
use ChrisWhite\B2\Exceptions\BadValueException;
88
use ChrisWhite\B2\Exceptions\BucketAlreadyExistsException;
9-
use ChrisWhite\B2\Exceptions\NotFoundException;
10-
use ChrisWhite\B2\Exceptions\FileNotPresentException;
119
use ChrisWhite\B2\Exceptions\BucketNotEmptyException;
10+
use ChrisWhite\B2\Exceptions\FileNotPresentException;
11+
use ChrisWhite\B2\Exceptions\NotFoundException;
1212
use GuzzleHttp\Psr7\Response;
1313

1414
class 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

Comments
 (0)