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

Merge branch '33-introduce-custom-growbrosexception-abstract-class' into 'main'

"Introduce custom "GrowBrosException" (abstract class?)"

Closes #33

See merge request !17
parents 391230d2 fa85cbd8
No related branches found
No related tags found
1 merge request!17"Introduce custom "GrowBrosException" (abstract class?)"
package hdm.mi.growbros.exceptions;
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(HttpStatus.INTERNAL_SERVER_ERROR, message);
}
public GrowBrosException(HttpStatus httpStatus, String message) {
super(httpStatus, message);
}
}
package hdm.mi.growbros.exceptions;
public abstract class GrowBrosFatalException extends Exception {
public GrowBrosFatalException(String message) {
super(message);
}
}
package hdm.mi.growbros.exceptions;
public class PlantNotFoundException extends RuntimeException {
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