34 lines
688 B
PHP
34 lines
688 B
PHP
<?php
|
|
|
|
|
|
namespace App\Aspect;
|
|
|
|
use Swoft\Aop\Annotation\Mapping\AfterThrowing;
|
|
use Swoft\Aop\Annotation\Mapping\Aspect;
|
|
use Swoft\Aop\Annotation\Mapping\PointAnnotation;
|
|
use Swoft\Bean\Annotation\Mapping\Inject;
|
|
use App\Bean\ResponseBean;
|
|
/**
|
|
* @Aspect(order=1)
|
|
* @PointAnnotation(
|
|
* include={
|
|
* Swoft\Http\Server\Annotation\Mapping\RequestMapping::class
|
|
* }
|
|
* )
|
|
*/
|
|
class FailAspect {
|
|
|
|
/**
|
|
* @Inject("ResponseBean")
|
|
*/
|
|
protected $response;
|
|
|
|
/**
|
|
* @param \Throwable $throwable
|
|
* @return array
|
|
* @AfterThrowing()
|
|
*/
|
|
public function FailError(\Throwable $throwable) {
|
|
return $this->response->fail($throwable);
|
|
}
|
|
} |