Skip to content

WrongStatusCodeException should make original message accessable #481

@FloSchramm

Description

@FloSchramm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions