Skip to content

Problem Details 类型

NENE2 的所有错误响应均返回 application/problem+json,遵循 RFC 9457

类型目录

typeHTTP 状态码title产生来源
…/not-found404Not Found路由未找到;指定 id 的 Note 或 Tag 不存在
…/method-not-allowed405Method Not Allowed已知路由的错误 HTTP 方法
…/invalid-json400Invalid JSON请求体为空、JSON 无效或非 JSON 对象
…/validation-failed422Validation Failed请求体无效或缺少必填字段
…/unauthorized401UnauthorizedBearer 令牌缺失或无效
…/too-many-requests429Too Many Requests超出速率限制(ThrottleMiddleware);包含 Retry-After 响应头
…/payload-too-large413Payload Too Large请求体超过配置的大小限制
…/internal-server-error500Internal Server Error未处理异常

基础 URI 前缀:https://nene2.dev/problems/

添加自定义类型

  1. 创建领域异常类(如 ProductNotFoundException)。
  2. 实现 DomainExceptionHandlerInterface,调用 ProblemDetailsResponseFactory::create()
  3. RuntimeServiceProvider 中注册处理程序。

请参考 NoteNotFoundExceptionHandlerTagNotFoundExceptionHandler 的具体实现。

基于 MIT 许可证发布。