-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PEPPER-1407 Added exception mapper to help handle attempts to insert …
…data that will break unique constraints or is otherwise considered duplicative.
- Loading branch information
Showing
4 changed files
with
75 additions
and
29 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
40 changes: 40 additions & 0 deletions
40
...pis/dsm-core/src/main/java/org/broadinstitute/dsm/exception/DuplicateEntityException.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,40 @@ | ||
package org.broadinstitute.dsm.exception; | ||
|
||
/** | ||
* Exception thrown when there is a duplicate value | ||
* and the user should try their operation again | ||
* after changing the duplicate value to a unique value | ||
*/ | ||
public class DuplicateEntityException extends RuntimeException { | ||
|
||
private final String entityName; | ||
|
||
private final String entityValue; | ||
|
||
/** | ||
* Create a new one in response to an attempt to save | ||
* a duplicte value | ||
* @param entityName the name of the entity, in a way that | ||
* makes sense to the user | ||
* @param entityValue the value of the entity | ||
*/ | ||
public DuplicateEntityException(String entityName, String entityValue) { | ||
this.entityName = entityName; | ||
this.entityValue = entityValue; | ||
} | ||
|
||
/** | ||
* The kind of entity that has a duplicate value, such as "filter" | ||
*/ | ||
public String getEntityName() { | ||
return entityName; | ||
} | ||
|
||
/** | ||
* The name of the entity that is duplicated, that the user | ||
* has control over and can change on a retry | ||
*/ | ||
public String getEntityValue() { | ||
return entityValue; | ||
} | ||
} |
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