Search

Chapter 9. Error handling

download PDF

Errors in Red Hat build of Rhea can be handled by intercepting named events corresponding to AMQP protocol or connection errors.

9.1. Handling connection and protocol errors

You can handle protocol-level errors by intercepting the following events:

  • connection_error
  • session_error
  • sender_error
  • receiver_error
  • protocol_error
  • error

These events are fired whenever there is an error condition with the specific object that is in the event. After calling the error handler, the corresponding <object>_close handler is also called.

The event argument has an error attribute for accessing the error object.

Example: Handling errors

container.on("error", function (event) {
    console.log("An error!", event.error);
});

Note

Because the close handlers are called in the event of any error, only the error itself needs to be handled within the error handler. Resource cleanup can be managed by close handlers. If there is no error handling that is specific to a particular object, it is typical to handle the general error event and not have a more specific handler.

Note

When reconnect is enabled and the remote server closes a connection with the amqp:connection:forced condition, the client does not treat it as an error and thus does not fire the connection_error event. The client instead begins the reconnection process.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.