Edit File: B2Exception.inc
<?php namespace B2\Exceptions; /** * Author: Shlomi * Date: Sep 3, 2017 6:09:32 PM * Founder: Shlomi Bazak (SBZsoft) (c) * File: B2Exception.inc * * Description: * */ // No direct access. defined("__NSS__") or die("Restrected Access."); class B2Exception extends \Exception { private static $exceptions = [ 'bad_json' => BadJsonException::class, 'bad_value' => BadValueException::class, 'duplicate_bucket_name' => DuplicateBucketException::class, 'not_found' => NotFoundException::class, 'file_not_present' => FileNotPresentException::class, 'cannot_delete_non_empty_bucket' => CannotDeleteBucket::class, 'unauthorized' => Unauthorized::class ]; public static function genException($json){ $code = $json['code']; $message = $json['message']; if(isset(self::$exceptions[$code])){ $class = self::$exceptions[$code]; return new $class($message); } return new B2Exception($message); } }