source: backend/src/main/java/com/finki/icare/exceptions/ICareException.java@ 700e2f9

main
Last change on this file since 700e2f9 was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago

Init

  • Property mode set to 100644
File size: 1006 bytes
Line 
1package com.finki.icare.exceptions;
2
3import lombok.Getter;
4import org.springframework.http.HttpStatus;
5
6@Getter
7public class ICareException extends RuntimeException {
8 private final HttpStatus status;
9
10 public ICareException(String message, HttpStatus status) {
11 super(message);
12 this.status = status;
13 }
14
15 public static ICareException notFound(String message) {
16 return new ICareException(message, HttpStatus.NOT_FOUND);
17 }
18
19 public static ICareException forbidden(String message) {
20 return new ICareException(message, HttpStatus.FORBIDDEN);
21 }
22
23 public static ICareException unauthorized(String message) {
24 return new ICareException(message, HttpStatus.UNAUTHORIZED);
25 }
26
27 public static ICareException badRequest(String message) {
28 return new ICareException(message, HttpStatus.BAD_REQUEST);
29 }
30
31 public static ICareException conflict(String message) {
32 return new ICareException(message, HttpStatus.CONFLICT);
33 }
34}
Note: See TracBrowser for help on using the repository browser.