Class ScxHttpException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cool.scx.http.exception.ScxHttpException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BadRequestException,ContentTooLargeException,ForbiddenException,InternalServerErrorException,MethodNotAllowedException,NotFoundException,UnauthorizedException,UnsupportedMediaTypeException,URITooLongException
ScxHttpException
这是一个基于 ScxHttpStatus 的运行时异常类, 用于表示 HTTP 请求处理过程中的异常情况.
该异常旨在处理 HTTP 规范中 4xx(客户端错误)和 5xx(服务器错误)序列的状态码, 表示请求失败的各种可能原因.
通过 ScxHttpStatus 提供了详细的状态码和描述信息, 使异常的语义更加清晰.
注意:
- 200 系列状态码(表示请求成功)或其他非异常状态码通常不应使用此类来表示, 因为它们不属于异常的范畴.
适用场景:
- 在 HTTP 请求处理失败时, 抛出此异常以便调用方捕获并作出相应处理.
- 结合
ScxHttpStatus使用, 可以快速标识具体的错误类型并生成标准化的响应.
使用示例:
throw new ScxHttpException(HttpStatus.NOT_FOUND, "Requested resource not found");
- Version:
- 0.0.1
- Author:
- scx567888
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionScxHttpException(ScxHttpStatus status) ScxHttpException(ScxHttpStatus status, String message) ScxHttpException(ScxHttpStatus status, String message, Throwable cause) ScxHttpException(ScxHttpStatus status, Throwable cause) -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ScxHttpException
-
ScxHttpException
-
ScxHttpException
-
ScxHttpException
-
-
Method Details
-
status
-