Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-4696: added specific exception classes for the Order Service #1860

Merged
merged 1 commit into from Oct 26, 2016

Conversation

samshuster
Copy link
Contributor

Description

Modifying some Order Exception definitions to be more in line with the messages.properties. Fixing test to map to these new definitions.

Related Issue

see https://issues.openmrs.org/browse/TRUNK-

Checklist:

  • [ x] My pull request only contains one single commit.
  • [ x] My pull request is based on the latest master branch
    git pull --rebase upstream master.
  • [x ] I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.
  • [ x] My code follows the code style of this project.
  • [ x] I have read the CONTRIBUTING document.
  • [x ] I have added tests to cover my changes.
  • [x ] All new and existing tests passed.

@mention-bot
Copy link

@samshuster, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bmamlin, @wluyima and @teleivo to be potential reviewers.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 55.542% when pulling f7b79fd on samshuster:TRUNK-4696 into f5ef7a7 on openmrs:master.

* The specific error classes define only a default constructor if they are meant to be used with only a single error message.
* In other cases, there should be static factory methods that can be used to create the error class with the specific error message needed.
*/
public class OrderExceptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samshuster do you mind throwing some more light as to why you prefer creating a new OrderExceptions class for grouping purposes instead of just putting them in the org.openmrs.api or any other package, as the rest of the existing custom exception classes? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will obviously defer to you on whats best.
But here is why I made the decision not to make them there own classes.

  1. There is a lot of exceptions being created and it would pollute the number of classes in that package.
  2. These exceptions are all similar to each other and it might make it easier on user to see a list of all different Order Exception classes.
  3. Unless static import used, when throwing them, the name is very expressive. new OrderExceptions.CannotEditExistingOrderException()

Downsides:

  1. Not consistent with rest of project
  2. OrderExceptions is essentially a package name. Making a separate package called orderexceptions would help alleviate concern 1 and 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will move them to custom exception package

public static final long serialVersionUID = 22121215L;

public CannotDiscontinueOrderWithActionException() {
super("Order.action.cannot.discontinued", new Object[] { DISCONTINUE }, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If just passing null for the third argument, why not just use the two argument constructor? :)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 55.669% when pulling 977cf97 on samshuster:TRUNK-4696 into c016290 on openmrs:master.

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

adding license to files
@samshuster samshuster force-pushed the TRUNK-4696 branch 2 times, most recently from 623ffe0 to b33cae6 Compare October 26, 2016 01:25
@coveralls
Copy link

Coverage Status

Coverage increased (+2.0e-05%) to 55.535% when pulling b33cae6 on samshuster:TRUNK-4696 into c016290 on openmrs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 55.669% when pulling b33cae6 on samshuster:TRUNK-4696 into c016290 on openmrs:master.

@dkayiwa dkayiwa merged commit 692ff64 into openmrs:master Oct 26, 2016
@samshuster samshuster deleted the TRUNK-4696 branch October 26, 2016 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants