-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1158 Provide meaningful user error messages for concurrency errors
- Refactored NotFoundException
- Loading branch information
Showing
6 changed files
with
77 additions
and
43 deletions.
There are no files selected for viewing
34 changes: 31 additions & 3 deletions
34
src/main/java/de/mpg/imeji/exceptions/NotFoundException.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,12 +1,40 @@ | ||
package de.mpg.imeji.exceptions; | ||
|
||
public class NotFoundException extends ImejiException { | ||
import java.util.Locale; | ||
|
||
import de.mpg.imeji.logic.config.Imeji; | ||
import de.mpg.imeji.logic.util.ObjectHelper; | ||
|
||
public class NotFoundException extends ImejiExceptionWithUserMessage { | ||
|
||
private static final long serialVersionUID = -6006945139992063194L; | ||
private String objectLabel; | ||
|
||
public NotFoundException(String message) { | ||
super(message, null); | ||
|
||
public NotFoundException(String internalMessage) { | ||
super(internalMessage, "error_resource_not_found"); | ||
// minimizeStacktrace(); | ||
} | ||
|
||
public NotFoundException(Object objectToFind, String internalMessage) { | ||
super(internalMessage, "error_not_found"); | ||
this.objectLabel = ObjectHelper.getGUILabel(objectToFind); | ||
} | ||
|
||
public NotFoundException(Object objectToFind) { | ||
super("error_not_found"); | ||
this.objectLabel = ObjectHelper.getGUILabel(objectToFind); | ||
} | ||
|
||
/** | ||
* Creates a user readable error message. | ||
* | ||
* @return error message | ||
*/ | ||
@Override | ||
public String getUserMessage(Locale locale) { | ||
String userMessage = | ||
Imeji.RESOURCE_BUNDLE.getLabel(this.objectLabel, locale) + " " + Imeji.RESOURCE_BUNDLE.getMessage(this.userMessageLabel, locale); | ||
return userMessage; | ||
} | ||
} |
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
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