-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from kbss-cvut/550-error-message-id
Localize error messages
- Loading branch information
Showing
8 changed files
with
66 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
package cz.cvut.kbss.analysis.dto.error; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class ErrorInfo { | ||
|
||
private String message; | ||
|
||
private String messageId; | ||
|
||
private String requestUri; | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/cz/cvut/kbss/analysis/exception/BadRequestException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
package cz.cvut.kbss.analysis.exception; | ||
|
||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
/** | ||
* Generic exception for bad requests. | ||
*/ | ||
@Getter | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public class BadRequestException extends RuntimeException { | ||
|
||
private final String messageId; | ||
|
||
public BadRequestException(String messageId, String message){ | ||
super(message); | ||
this.messageId = messageId; | ||
} | ||
|
||
public BadRequestException(String message) { | ||
super(message); | ||
this.messageId = null; | ||
} | ||
|
||
public BadRequestException(String message, Throwable cause) { | ||
super(message, cause); | ||
this.messageId = null; | ||
} | ||
} |
14 changes: 13 additions & 1 deletion
14
src/main/java/cz/cvut/kbss/analysis/exception/LogicViolationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
package cz.cvut.kbss.analysis.exception; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class LogicViolationException extends RuntimeException { | ||
public LogicViolationException() { } | ||
|
||
private final String messageId; | ||
|
||
public LogicViolationException(String messageId, String message){ | ||
super(message); | ||
this.messageId = messageId; | ||
} | ||
|
||
public LogicViolationException(String message) { | ||
super(message); | ||
messageId = null; | ||
} | ||
|
||
public LogicViolationException(String message, Throwable cause) { | ||
super(message, cause); | ||
messageId = null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters