Skip to content
Snippets Groups Projects
Commit fa85cbd8 authored by Lukas Karsch's avatar Lukas Karsch
Browse files

#33 custom exception now extends ResponseStatusException

parent 465fd683
No related branches found
No related tags found
1 merge request!17"Introduce custom "GrowBrosException" (abstract class?)"
package hdm.mi.growbros.exceptions;
public abstract class GrowBrosException extends RuntimeException {
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;
public abstract class GrowBrosException extends ResponseStatusException {
/**
* Creates a ResponseStatus exception with the given message and a response status of 500 (internal server error)
*
* @param message Error message
*/
public GrowBrosException(String message) {
super(message);
super(HttpStatus.INTERNAL_SERVER_ERROR, message);
}
public GrowBrosException(HttpStatus httpStatus, String message) {
super(httpStatus, message);
}
}
package hdm.mi.growbros.exceptions;
import org.springframework.http.HttpStatus;
public class PlantNotFoundException extends GrowBrosException {
public PlantNotFoundException(Long id) {
super(String.format("Plant with id '%d' was not found", id));
super(HttpStatus.NOT_FOUND, String.format("Plant with id '%d' was not found", id));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment