Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents

Error catalogue

There is interface org.openhubframework.openhub.api.exception.ErrorExtEnum for defining own error catalogue that is displayed in admin GUI.

It allows consuments of your services to see possible error codes and be able to handle them.

Code Block
/**
 * Catalog of internal error codes.
 *
 * @author Petr Juza
 */
@ErrorCodeCatalog("OHF")
public enum InternalErrorEnum implements ErrorExtEnum {

    /**
     * unspecified error
     */
    E100("unspecified error"),

    /**
     * the request message is not valid against to XSD schema
     */
    E101("the request message is not valid against to XSD schema"),

    /**
     * the validation error
     */
    E102("the validation error"),

    /**
     * I/O error during communication with target system
     */
    E103("I/O error during communication with target system"),

Exceptions hierarchy

All OpenHub framework exceptions are in package org.openhubframework.openhub.api.exception:

  • IntegrationException: parent Exception for all OpenHub framework exceptions
    • LockFailureException: unsuccessful getting lock for the record from DB (most often it means that another process was faster and acquired lock before)
    • MultipleDataFoundException: one record was expected but more records were found
    • NoDataFoundException: at least one records was expected but no record was found
    • ThrottlingExceededException: this exception is thrown when throttling limits were exceeded
    • StoppingException: when OpenHub is in stopping mode then this exception will be thrown when new requests arrive
    • ValidationIntegrationException: input data are not valid
      • IllegalDataException: wrong data

How it works?

Tip

Basic error handling concept is well-documented in Apache Camel.

Basic algorithm of error handling is implemented in parent class of routes - org.openhubframework.openhub.api.route.AbstractBasicRoute.

...

Code Block
titlesynchronous error handling
.onException(WebServiceIOException.class)
	.handled(true)
    .setProperty(ExceptionTranslator.EXCEPTION_ERROR_CODE, constant(ErrorEnum.E600))
    .process(ExceptionTranslator.getInstance())
	.end()
.onException(FATAL_EXCEPTIONS)
    .handled(true)
    .setProperty(ExceptionTranslator.EXCEPTION_ERROR_CODE, constant(ErrorEnum.E601))
    .process(ExceptionTranslator.getInstance())
    .end()
.onException(NEXT_HANDLING_EXCEPTIONS)
    .handled(true)
    .setProperty(ExceptionTranslator.EXCEPTION_ERROR_CODE, constant(ErrorEnum.E602))
    .process(ExceptionTranslator.getInstance())
    .end()

.to(getSapUri())
// explicitly converts to UTF-8
.convertBodyTo(String.class, "UTF-8")
// XML -> specific payload implementation of child for error check
.unmarshal(getUnmarshalDataFormat())

Custom error processing

Error handling concept in described in Apache Camel where you can find more details.

...