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

WrongStatusCodeException should make original message accessable #481

Open
flowrider3000 opened this issue Jul 3, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@flowrider3000
Copy link

flowrider3000 commented Jul 3, 2023

Background

As an openEHR_SDK user, I want to have access to the original error message from ehrbase, in case I submitted an invalid composition and ehrbase rejects the composition with HTTP 400, which leads to a WrongStatusCodeException in the openEHR_SDK.

At the moment, the error message from EHRbase get's concatenated with additional information here https://github.com/ehrbase/openEHR_SDK/blame/5cba04bce86e8a6fec6592dd3db7fed71063ed30/util/src/main/java/org/ehrbase/openehr/sdk/util/exception/WrongStatusCodeException.java#L29.

Enhancement

Change WrongeStatusCodeException to something like this

public class WrongStatusCodeException extends ClientException {
  private final int actualStatusCode;
  private final int[] expectedStatusCode;
  private final String originalMessage;

  public WrongStatusCodeException(String message, int actualStatusCode, int... expectedStatusCode) {
    super(String.format("Wrong Status code. Expected: %s. Got: %s. Error message: %s", Arrays.toString(expectedStatusCode), actualStatusCode, message));
    this.originalMessage = message;
    this.actualStatusCode = actualStatusCode;
    this.expectedStatusCode = expectedStatusCode;
  }

  public int getActualStatusCode() {
    return this.actualStatusCode;
  }

  public int[] getExpectedStatusCode() {
    return this.expectedStatusCode;
  }

  public String getOriginalMessage {
    return this.message
  }
}

Discussion

No response

Further information

No response

@flowrider3000 flowrider3000 added the enhancement New feature or request label Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant