integration-impl/src/main/java/se/idsec/signservice/integration/core/error/impl/SignServiceIntegrationErrorUtils.java
public static Exception toException(final String errorBody) {
    try {
      final SignServiceIntegrationErrorBody body = objectMapper.readValue(errorBody, SignServiceIntegrationErrorBody.class);

      if (body.getDssError() != null) {
        if (DSSStatusCodes.DSS_MINOR_USER_CANCEL.equals(body.getDssError().getMinorCode())) {
          return new SignResponseCancelStatusException();
        }
        else {
          return new SignResponseErrorStatusException(body.getDssError().getMajorCode(), body.getDssError().getMinorCode());
        }
      }
      if (body.getValidationError() != null) {
        if (body.getValidationError().getDetails() != null) {
          return new InputValidationException(body.getValidationError().getObject(), body.getMessage(),
            body.getValidationError().getDetails());
        }
        else {
          return new InputValidationException(body.getValidationError().getObject(), body.getMessage());
        }
      }
      if (PdfSignaturePageFullException.class.getName().equals(body.getExceptionClass())) {
        return new PdfSignaturePageFullException(body.getMessage());
      }

      // Else, return a generic exception ...
      return new GenericSignServiceIntegrationException(
        new ErrorCode(body.getErrorCode()), body.getMessage(), body.getStatus());
    }
    catch (JsonProcessingException e) {
      log.error("Could not map errorBody to SignServiceIntegrationErrorBody", e);
      return new InternalSignServiceIntegrationException(new ErrorCode.Code("unknown"), "Unknwon error " + errorBody);
    }
  }
/**
   * A utility method that can be used by clients to a SignService Integration service running as a REST server. The
   * method converts the error body into an exception.
   * 
   * @param errorBody
   *          the error body
   * @return an exception
   */
A utility method that can be used by clients to a SignService Integration service running as a REST server. The
method converts the error body into an exception.

@param errorBody
the error body
@return an exception
A utility method that can be used by clients to a SignService Integration service running as a REST server . The method converts the error body into an exception . @param errorBody the error body @return an exception
public static Exception toException(final String errorBody) {
    try {
      final SignServiceIntegrationErrorBody body = objectMapper.readValue(errorBody, SignServiceIntegrationErrorBody.class);
      if (body.getDssError() != null) {
        if (DSSStatusCodes.DSS_MINOR_USER_CANCEL.equals(body.getDssError().getMinorCode())) {
          return new SignResponseCancelStatusException();
        }
        else {
          return new SignResponseErrorStatusException(body.getDssError().getMajorCode(), body.getDssError().getMinorCode());
        }
      }
      if (body.getValidationError() != null) {
        if (body.getValidationError().getDetails() != null) {
          return new InputValidationException(body.getValidationError().getObject(), body.getMessage(),
            body.getValidationError().getDetails());
        }
        else {
          return new InputValidationException(body.getValidationError().getObject(), body.getMessage());
        }
      }
      if (PdfSignaturePageFullException.class.getName().equals(body.getExceptionClass())) {
        return new PdfSignaturePageFullException(body.getMessage());
      }
      return new GenericSignServiceIntegrationException(
        new ErrorCode(body.getErrorCode()), body.getMessage(), body.getStatus());
    }
    catch (JsonProcessingException e) {
      log.error("Could not map errorBody to SignServiceIntegrationErrorBody", e);
      return new InternalSignServiceIntegrationException(new ErrorCode.Code("unknown"), "Unknwon error " + errorBody);
    }
  }
public static Exception toException ( final String errorBody ) { try { final SignServiceIntegrationErrorBody body = objectMapper . readValue ( errorBody , SignServiceIntegrationErrorBody . class ) ; if ( body . getDssError ( ) != null ) { if ( DSSStatusCodes . DSS_MINOR_USER_CANCEL . equals ( body . getDssError ( ) . getMinorCode ( ) ) ) { return new SignResponseCancelStatusException ( ) ; } else { return new SignResponseErrorStatusException ( body . getDssError ( ) . getMajorCode ( ) , body . getDssError ( ) . getMinorCode ( ) ) ; } } if ( body . getValidationError ( ) != null ) { if ( body . getValidationError ( ) . getDetails ( ) != null ) { return new InputValidationException ( body . getValidationError ( ) . getObject ( ) , body . getMessage ( ) , body . getValidationError ( ) . getDetails ( ) ) ; } else { return new InputValidationException ( body . getValidationError ( ) . getObject ( ) , body . getMessage ( ) ) ; } } if ( PdfSignaturePageFullException . class . getName ( ) . equals ( body . getExceptionClass ( ) ) ) { return new PdfSignaturePageFullException ( body . getMessage ( ) ) ; } return new GenericSignServiceIntegrationException ( new ErrorCode ( body . getErrorCode ( ) ) , body . getMessage ( ) , body . getStatus ( ) ) ; } catch ( JsonProcessingException e ) { log . error ( "Could not map errorBody to SignServiceIntegrationErrorBody" , e ) ; return new InternalSignServiceIntegrationException ( new ErrorCode . Code ( "unknown" ) , "Unknwon error " + errorBody ) ; } }
A utility method that can be used by clients to a SignService Integration service running as a REST server.
A utility method that can be used by clients to a SignService Integration service running as a REST server .
// Else, return a generic exception ...