JoinPoint $joinPoint, \Throwable $exception): void
{
// 异常后通知:在目标方法抛出异常后执行
}
}
```
### 方式二:>afterLogic($result);
}
```
### AfterReturning(返回后通知)
在目标方法正常返回后执行(不抛出异常时),可以:
- 记录返回值
- 处理返回结果
- 发送通知returned', ['result' => $result]);
}
```
### AfterThrowing(异常后通知)
在目标方法抛出异常后执行,可以:
- 记录异常
- 错误处理
- 发送告警获取返回值和异常
$returnValue = $joinPoint->getReturnValue();
$exception = $joinPoint->getException();
// 数据存储(用于切面之间传递数据)
$joinPoint->setData('key', $value);
$value = $joinPoint->getData('key', $default);
$allData