This commit is contained in:
yyh931018@qq.com
2022-09-08 17:11:02 +08:00
parent 1b0c8f4196
commit d1f6cbd57e
75 changed files with 9148 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
<?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'] : '';
}
}