Commit 2761996c by yeran

remove license

1 parent 320e8126
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
"description": "Phalcon", "description": "Phalcon",
"keywords": ["phwoolcon"], "keywords": ["phwoolcon"],
"type": "library", "type": "library",
"version": "1.0.1", "version": "1.0.2",
"license": "Apache-2.0", "license": "",
"authors": [ "authors": [
{ {
"name": "ldy", "name": "ldy",
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
"ext-phalcon": "~3.0", "ext-phalcon": "~3.0",
"symfony/console": "~3.0", "symfony/console": "~3.0",
"pda/pheanstalk": "~3.1", "pda/pheanstalk": "~3.1",
"swiftmailer/swiftmailer": "~5.4|~6.0", "swiftmailer/swiftmailer": "~5.4|~6.0"
"opis/closure": "3.0.1"
}, },
"require-dev": { "require-dev": {
}, },
......
<?php
/**
* API异常处理
*/
namespace Phwoolcon\Exception\Http;
use Phwoolcon\ErrorCodes;
use Throwable;
class ApiException extends \Exception
{
public function __construct($message = '', int $code = 0, Throwable $previous = null)
{
if (empty($message)) {
$errorCode = ErrorCodes::getCodeMsg($code);
$message = ($errorCode && count($errorCode) == 2) ? $errorCode[1] : '';
}
parent::__construct($message, $code, $previous);
}
public function getHeaders()
{
return [
'content-type: application/vnd.api+json',
'exception-type: ApiException',
];
}
public function getBody()
{
return json_encode([
'jsonapi' => ['version' => '1.0'],
'error' => $this->getCode(),
'error_reason' => $this->getMessage()
]);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!