-
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 #158 from kbss-cvut/550-error-message-id
Provide messageArguments for exceptions
- Loading branch information
Showing
11 changed files
with
151 additions
and
28 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
30 changes: 30 additions & 0 deletions
30
src/main/java/cz/cvut/kbss/analysis/exception/BadCredentialsException.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cz.cvut.kbss.analysis.exception; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.Map; | ||
|
||
@Getter | ||
@Setter | ||
public class BadCredentialsException extends org.springframework.security.authentication.BadCredentialsException { | ||
|
||
private final String messageId; | ||
private Map<String, String> messageArguments; | ||
|
||
public BadCredentialsException(String message) { | ||
super(message); | ||
this.messageId = null; | ||
} | ||
|
||
public BadCredentialsException(String message, Throwable cause) { | ||
super(message, cause); | ||
this.messageId = null; | ||
} | ||
|
||
public BadCredentialsException(String messageId, String message, Map<String, String> args){ | ||
super(message); | ||
this.messageId = messageId; | ||
messageArguments = args; | ||
} | ||
} |
22 changes: 18 additions & 4 deletions
22
src/main/java/cz/cvut/kbss/analysis/exception/CalculationException.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
15 changes: 13 additions & 2 deletions
15
src/main/java/cz/cvut/kbss/analysis/exception/EntityNotFoundException.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,24 @@ | ||
package cz.cvut.kbss.analysis.exception; | ||
|
||
import lombok.Getter; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Getter | ||
public class EntityNotFoundException extends FtaFmeaException { | ||
|
||
public EntityNotFoundException(String message) { | ||
private final String messageId; | ||
private Map<String, String> messageArguments; | ||
|
||
public EntityNotFoundException(String messageId, String message, Map<String, String> args) { | ||
super(message); | ||
this.messageId = messageId; | ||
this.messageArguments = args; | ||
} | ||
|
||
public static EntityNotFoundException create(String resourceName, Object identifier) { | ||
return new EntityNotFoundException(resourceName + " identified by " + identifier + " not found."); | ||
return new EntityNotFoundException("error.entityNotFound",resourceName + " identified by " + identifier + " not found.", Map.of("resourceName", resourceName, "identifier", identifier.toString())); | ||
} | ||
|
||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/cz/cvut/kbss/analysis/exception/UsernameNotAvailableException.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,7 +1,26 @@ | ||
package cz.cvut.kbss.analysis.exception; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.Map; | ||
|
||
@Getter | ||
@Setter | ||
public class UsernameNotAvailableException extends RuntimeException { | ||
|
||
private final String messageId; | ||
private Map<String, String> messageArguments; | ||
|
||
public UsernameNotAvailableException(String message) { | ||
super(message); | ||
messageId = null; | ||
} | ||
|
||
public UsernameNotAvailableException(String messageId, String message, Map<String, String> args){ | ||
super(message); | ||
this.messageId = messageId; | ||
messageArguments = args; | ||
} | ||
|
||
} |
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