Function amqp_error_string2

Synopsis

#include <librabbitmq/amqp.h>

const char * amqp_error_string2(int err)

Description

Get the error string for the given error code.

Get an error string associated with an error code. The string is statically allocated and does not need to be freed

Parameters:

[ in ] err - the error code

Return
the error string
Since
v0.4.0

Mentioned in

Source

Lines 124-161 in librabbitmq/amqp_api.c. Line 2081 in librabbitmq/amqp.h.

const char *amqp_error_string2(int code) {
  const char *error_string;
  size_t category = (((-code) & ERROR_CATEGORY_MASK) >> 8);
  size_t error = (-code) & ERROR_MASK;

  switch (category) {
    case EC_base:
      if (error < (sizeof(base_error_strings) / sizeof(char *))) {
        error_string = base_error_strings[error];
      } else {
        error_string = unknown_error_string;
      }
      break;

    case EC_tcp:
      if (error < (sizeof(tcp_error_strings) / sizeof(char *))) {
        error_string = tcp_error_strings[error];
      } else {
        error_string = unknown_error_string;
      }
      break;

    case EC_ssl:
      if (error < (sizeof(ssl_error_strings) / sizeof(char *))) {
        error_string = ssl_error_strings[error];
      } else {
        error_string = unknown_error_string;
      }

      break;

    default:
      error_string = unknown_error_string;
      break;
  }

  return error_string;
}





Add Discussion as Guest

Log in to DocsForge