-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TRUNK-4696: added specific exception classes for the Order Service
Modifying some Order Exception definitions to be more in line with the messages.properties. Fixing test to map to these new definitions. moving exceptions to separate classes. Changing call to use overloaded method without throwable
- Loading branch information
1 parent
c016290
commit 991a898
Showing
13 changed files
with
263 additions
and
58 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
19 changes: 19 additions & 0 deletions
19
...c/main/java/org/openmrs/api/order/exceptions/CannotDeleteOrderPropertyInUseException.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,19 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when trying to delete an order property that is still in use. | ||
*/ | ||
public class CannotDeleteOrderPropertyInUseException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121221L; | ||
|
||
private CannotDeleteOrderPropertyInUseException(String message) { | ||
super(message); | ||
} | ||
|
||
public static CannotDeleteOrderPropertyInUseException withProperty(String property) { | ||
return new CannotDeleteOrderPropertyInUseException(String.format("Order.%s.cannot.delete", property)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
.../org/openmrs/api/order/exceptions/CannotDiscontinueAlreadyDiscontinuedOrderException.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,15 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when the Order has already been discontinued. | ||
*/ | ||
public class CannotDiscontinueAlreadyDiscontinuedOrderException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121214L; | ||
|
||
public CannotDiscontinueAlreadyDiscontinuedOrderException() { | ||
super("Order.stopped.cannot.discontinued"); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...main/java/org/openmrs/api/order/exceptions/CannotDiscontinueOrderWithActionException.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,17 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import static org.openmrs.Order.Action.DISCONTINUE; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown with trying to discontinue an order with a specific action that cannot be discontinued. | ||
*/ | ||
public class CannotDiscontinueOrderWithActionException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121215L; | ||
|
||
public CannotDiscontinueOrderWithActionException() { | ||
super("Order.action.cannot.discontinued", new Object[] { DISCONTINUE }, null); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...c/main/java/org/openmrs/api/order/exceptions/CannotEditAlreadyExistingOrderException.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,15 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when the OrderAlreadyExists. | ||
*/ | ||
public class CannotEditAlreadyExistingOrderException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121213L; | ||
|
||
public CannotEditAlreadyExistingOrderException() { | ||
super("Order.cannot.edit.existing"); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...src/main/java/org/openmrs/api/order/exceptions/CannotEditOrderPropertyInUseException.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,19 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when trying to edit an order property which is still in use. | ||
*/ | ||
public class CannotEditOrderPropertyInUseException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121220L; | ||
|
||
private CannotEditOrderPropertyInUseException(String message) { | ||
super(message); | ||
} | ||
|
||
public static CannotEditOrderPropertyInUseException withProperty(String property) { | ||
return new CannotEditOrderPropertyInUseException(String.format("Order.%s.cannot.edit", property)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...a/org/openmrs/api/order/exceptions/CannotStopRetrospectiveDiscontinuedOrderException.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,15 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when trying to stop a retrospective discontinued order. | ||
*/ | ||
public class CannotStopRetrospectiveDiscontinuedOrderException extends APIException { | ||
|
||
public static final long serialVersionUID = 22221215L; | ||
|
||
public CannotStopRetrospectiveDiscontinuedOrderException() { | ||
super("Order.retrospective.stopped.cannot.discontinued"); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
api/src/main/java/org/openmrs/api/order/exceptions/CannotUnvoidOrderException.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,15 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when an attempt to unvoid an order fails. | ||
*/ | ||
public class CannotUnvoidOrderException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121315L; | ||
|
||
public CannotUnvoidOrderException(String action) { | ||
super("Order.action.cannot.unvoid", new Object[] { action }); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../main/java/org/openmrs/api/order/exceptions/EditedOrderDoesNotMatchPreviousException.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,19 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when the new edited order contains modified properties that must be the same as previous order. | ||
*/ | ||
public class EditedOrderDoesNotMatchPreviousException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121218L; | ||
|
||
public EditedOrderDoesNotMatchPreviousException(String message) { | ||
super(message); | ||
} | ||
|
||
public EditedOrderDoesNotMatchPreviousException(String message, Object[] params) { | ||
super(message, params); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
api/src/main/java/org/openmrs/api/order/exceptions/InvalidOrderException.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,15 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when the order is invalid. | ||
*/ | ||
public class InvalidOrderException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121219L; | ||
|
||
public InvalidOrderException(String message) { | ||
super(message); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
api/src/main/java/org/openmrs/api/order/exceptions/PreviousOrderRequiredException.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,15 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when a previous order is required. | ||
*/ | ||
public class PreviousOrderRequiredException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121216L; | ||
|
||
public PreviousOrderRequiredException() { | ||
super("Order.previous.required"); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
api/src/main/java/org/openmrs/api/order/exceptions/UnchangeableOrderPropertyException.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,19 @@ | ||
package org.openmrs.api.order.exceptions; | ||
|
||
import org.openmrs.api.APIException; | ||
|
||
/** | ||
* Thrown when trying to change unchangeable order properties. | ||
*/ | ||
public class UnchangeableOrderPropertyException extends APIException { | ||
|
||
public static final long serialVersionUID = 22121217L; | ||
|
||
private UnchangeableOrderPropertyException(String message) { | ||
super(message); | ||
} | ||
|
||
public static UnchangeableOrderPropertyException withProperty(String property) { | ||
return new UnchangeableOrderPropertyException(String.format("Order.cannot.change.%s", property)); | ||
} | ||
} |
Oops, something went wrong.