NATS C Client with JetStream and Streaming support 3.9.0-beta The nats.io C Client, Supported by Synadia Communications Inc.

Macros | Functions
microError
EXPERIMENTAL - Microservices » Functions

## Macros
#define | microError_Ignore(__err) microError_Destroy(__err)

## Functions
NATS_EXTERN microError * | micro_Errorf (const char *format,...)
| creates a new microError, with a printf-like formatted message. More...
NATS_EXTERN microError * | micro_ErrorfCode (int code, const char *format,...)
| creates a new microError, with a code and a printf-like formatted message. More...
NATS_EXTERN microError * | micro_ErrorFromStatus (natsStatus s)
| Wraps a NATS status into a microError, if not a NATS_OK. More...
NATS_EXTERN int | microError_Code (microError *err)
| returns the int code of the error. More...
NATS_EXTERN void | microError_Destroy (microError *err)
| destroys a microError. More...
NATS_EXTERN natsStatus | microError_Status (microError *err)
| Returns the NATS status associated with the error. More...
NATS_EXTERN const char * | microError_String (microError *err, char *buf, size_t len)
| Returns a printable string with the error message. More...
NATS_EXTERN microError * | microError_Wrapf (microError *err, const char *format,...)
| Wraps an exising microError with a higher printf-like formatted message. More...

## Detailed Description

Functions that create and manipulate microError.

## Macro Definition Documentation

## ◆ microError_Ignore

#define microError_Ignore | ( |  | __err | ) | microError_Destroy(__err)

## Function Documentation

## ◆ micro_Errorf()

NATS_EXTERN microError* micro_Errorf | ( | const char * | format,
|  |  | ...
| ) |  |

Note
  Errors must be freed with microError_Destroy, but often they are simply returned up the call stack.

Parameters

  format | printf-like format.

Returns
  a new microError or micro_ErrorOutOfMemory.

## ◆ micro_ErrorfCode()

NATS_EXTERN microError* micro_ErrorfCode | ( | int | code,
|  | const char * | format,
|  |  | ...
| ) |  |

Note
  Errors must be freed with microError_Destroy, but often they are simply returned up the call stack.

Parameters

  code | an `int` code, loosely modeled after the HTTP status code.
  format | printf-like format.

Returns
  a new microError or micro_ErrorOutOfMemory.

## ◆ micro_ErrorFromStatus()

NATS_EXTERN microError* micro_ErrorFromStatus | ( | natsStatus | s | ) |

Parameters

  s | NATS status of receiving the response.

Returns
  a new microError or `NULL` if no error if found.

## ◆ microError_Code()

NATS_EXTERN int microError_Code | ( | microError * | err | ) |

Parameters

  err | the error.

Returns
  the int code.

## ◆ microError_Destroy()

NATS_EXTERN void microError_Destroy | ( | microError * | err | ) |

Parameters

  err | the error.

## ◆ microError_Status()

NATS_EXTERN natsStatus microError_Status | ( | microError * | err | ) |

Parameters

  err |

Returns
  the status

## ◆ microError_String()

NATS_EXTERN const char* microError_String | ( | microError * | err,
|  | char * | buf,
|  | size_t | len
| ) |  |

This function outputs into a user-provided buffer, and returns a "`%s`-able" pointer to it.

Parameters

  err | the error.
  buf | the output buffer.
  len | the capacity of the output buffer.

Returns
  `buf`

## ◆ microError_Wrapf()

NATS_EXTERN microError* microError_Wrapf | ( | microError * | err,
|  | const char * | format,
|  |  | ...
| ) |  |

Warning
  The original error may be freed and should not be refered to after having been wrapped.

Parameters

  err | the original error
  format | the new message to prepend to the original error message.
  ... |

Returns
  a new, wrapped, error.