Skip to content

Commit

Permalink
✨ feat(RestServerException.java): Add detailed Javadoc comments and…
Browse files Browse the repository at this point in the history
… static factory methods for constructing `RestServerException`.
  • Loading branch information
vnobo committed Jan 2, 2025
1 parent c99842a commit bf041d8
Showing 1 changed file with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,45 @@
@EqualsAndHashCode(callSuper = true)
public class RestServerException extends ServerErrorException {


/**
* Constructs a new RestServerException with the specified detail message and cause.
*
* @param reason the detail message (which is saved for later retrieval by the {@link Throwable#getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
*/
public RestServerException(String reason, Throwable cause) {
super(reason, cause);
}

/**
* Constructs a new RestServerException with the specified detail message, handler method, and cause.
*
* @param reason the detail message (which is saved for later retrieval by the {@link Throwable#getMessage()} method).
* @param handlerMethod the method that caused the exception.
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
*/
public RestServerException(String reason, Method handlerMethod, Throwable cause) {
super(reason, handlerMethod, cause);
}

/**
* Constructs a new RestServerException with the specified detail message, method parameter, and cause.
*
* @param reason the detail message (which is saved for later retrieval by the {@link Throwable#getMessage()} method).
* @param parameter the method parameter that caused the exception.
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
*/
public RestServerException(String reason, MethodParameter parameter, Throwable cause) {
super(reason, parameter, cause);
}

/**
* Creates a new RestServerException with the specified detail message and cause.
*
* @param reason the detail message.
* @param cause the cause.
* @return a new instance of RestServerException.
*/
public static RestServerException withMsg(String reason, Throwable cause) {
var ex = new RestServerException(reason, cause);
ex.setTitle(reason);
Expand All @@ -49,10 +75,26 @@ public static RestServerException withMsg(String reason, Throwable cause) {
return ex;
}

/**
* Creates a new RestServerException with the specified detail message, handler method, and cause.
*
* @param reason the detail message.
* @param handlerMethod the method that caused the exception.
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
* @return a new instance of RestServerException.
*/
public static RestServerException withMsg(String reason, Method handlerMethod, @Nullable Throwable cause) {
return new RestServerException(reason, handlerMethod, cause);
}

/**
* Creates a new RestServerException with the specified detail message, method parameter, and cause.
*
* @param reason the detail message.
* @param parameter the method parameter that caused the exception.
* @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method).
* @return a new instance of RestServerException.
*/
public static RestServerException withMsg(String reason, MethodParameter parameter, Throwable cause) {
return new RestServerException(reason, parameter, cause);
}
Expand Down

0 comments on commit bf041d8

Please sign in to comment.