io.github.hison.api.exception.ApiException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-link Show documentation
Show all versions of api-link Show documentation
API-Link is a novel solution for Spring projects, aimed at streamlining development by eliminating the need for individual controllers. It allows developers to use a single 'cmd' value to invoke service layer methods, simplifying workflow and boosting productivity.
The newest version!
package io.github.hison.api.exception;
/**
*
* Custom exception class for handling API-related exceptions, particularly used within the ApiController.
* This exception extends the standard RuntimeException and provides additional functionality
* to include an error code with the exception message. It is designed to catch systemic errors
* occurring within the ApiController and then be passed to the ApiHandler's handleApiException method.
*
* Key Features:
*
* - Standard exception message handling with the addition of an error code.
* - Integrates with ApiHandler to allow structured error handling in API operations.
*
* Usage and Handling:
*
* // Throwing an ApiException
* throw new ApiException("Error processing request", "APIERROR001");
*
* // Handling in ApiHandler
* public ResponseEntity<DataWrapper> handleApiException(ApiException e, DataWrapper dw, HttpServletRequest req) {
* // Custom error logic here
* }
*
*
* ApiException is vital for structured error handling in API operations, enabling developers to
* write custom error logic within ApiHandler's handleApiException method.
*
* @author Hani son
* @version 1.0.0
*/
public class ApiException extends RuntimeException {
private String code = "APIERROR";
public ApiException(String message) {
super(message);
}
public ApiException(String message, String code) {
super(message);
this.code = code;
}
public String getCode() {
return this.code;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy