123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace OSS\Core;
- /**
- * Class OssException
- *
- * OssClient在使用的时候,所抛出的异常,用户在使用OssClient的时候,要Try住相关代码,
- * try的Exception应该是OssException,其中会得到相关异常原因
- *
- * @package OSS\Core
- */
- class OssException extends \Exception
- {
- private $details = array();
- function __construct($details)
- {
- if (is_array($details)) {
- $message = $details['code'] . ': ' . $details['message']
- . ' RequestId: ' . $details['request-id'];
- parent::__construct($message);
- $this->details = $details;
- } else {
- $message = $details;
- parent::__construct($message);
- }
- }
- public function getHTTPStatus()
- {
- return isset($this->details['status']) ? $this->details['status'] : '';
- }
- public function getRequestId()
- {
- return isset($this->details['request-id']) ? $this->details['request-id'] : '';
- }
- public function getErrorCode()
- {
- return isset($this->details['code']) ? $this->details['code'] : '';
- }
- public function getErrorMessage()
- {
- return isset($this->details['message']) ? $this->details['message'] : '';
- }
- public function getDetails()
- {
- return isset($this->details['body']) ? $this->details['body'] : '';
- }
- }
|