# Error Reporting

**API Group:** `xmlsec_core_errors`

Error codes and error-reporting functions.

Error reporting and logging functions.

## Macros

### `XMLSEC_ERRORS_R_XMLSEC_FAILED`

*Defined as:* `1`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L25)

An XMLSec function failed.

---

### `XMLSEC_ERRORS_R_MALLOC_FAILED`

*Defined as:* `2`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L30)

Failed to allocate memory error.

---

### `XMLSEC_ERRORS_R_STRDUP_FAILED`

*Defined as:* `3`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L35)

Failed to duplicate string error.

---

### `XMLSEC_ERRORS_R_CRYPTO_FAILED`

*Defined as:* `4`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L40)

Crypto (e.g. OpenSSL) function failed.

---

### `XMLSEC_ERRORS_R_XML_FAILED`

*Defined as:* `5`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L45)

LibXML function failed.

---

### `XMLSEC_ERRORS_R_XSLT_FAILED`

*Defined as:* `6`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L50)

LibXSLT function failed.

---

### `XMLSEC_ERRORS_R_IO_FAILED`

*Defined as:* `7`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L55)

IO operation failed.

---

### `XMLSEC_ERRORS_R_DISABLED`

*Defined as:* `8`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L61)

The feature is disabled during compilation.

The feature is disabled during compilation. Check './configure –help' for details on how to enable it.

---

### `XMLSEC_ERRORS_R_NOT_IMPLEMENTED`

*Defined as:* `9`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L66)

Feature is not implemented.

---

### `XMLSEC_ERRORS_R_INVALID_CONFIG`

*Defined as:* `10`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L71)

The configuration is invalid.

---

### `XMLSEC_ERRORS_R_INVALID_SIZE`

*Defined as:* `11`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L76)

Invalid size.

---

### `XMLSEC_ERRORS_R_INVALID_DATA`

*Defined as:* `12`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L81)

Invalid data.

---

### `XMLSEC_ERRORS_R_INVALID_RESULT`

*Defined as:* `13`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L86)

Invalid result.

---

### `XMLSEC_ERRORS_R_INVALID_TYPE`

*Defined as:* `14`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L91)

Invalid type.

---

### `XMLSEC_ERRORS_R_INVALID_OPERATION`

*Defined as:* `15`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L96)

Invalid operation.

---

### `XMLSEC_ERRORS_R_INVALID_STATUS`

*Defined as:* `16`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L101)

Invalid status.

---

### `XMLSEC_ERRORS_R_INVALID_FORMAT`

*Defined as:* `17`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L106)

Invalid format.

---

### `XMLSEC_ERRORS_R_DATA_NOT_MATCH`

*Defined as:* `18`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L111)

The data do not match our expectation.

---

### `XMLSEC_ERRORS_R_INVALID_VERSION`

*Defined as:* `19`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L116)

Version mismatch.

---

### `XMLSEC_ERRORS_R_INVALID_NODE`

*Defined as:* `21`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L121)

Invalid node.

---

### `XMLSEC_ERRORS_R_INVALID_NODE_CONTENT`

*Defined as:* `22`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L126)

Invalid node content.

---

### `XMLSEC_ERRORS_R_INVALID_NODE_ATTRIBUTE`

*Defined as:* `23`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L131)

Invalid node attribute.

---

### `XMLSEC_ERRORS_R_MISSING_NODE_ATTRIBUTE`

*Defined as:* `25`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L136)

Missing node attribute.

---

### `XMLSEC_ERRORS_R_NODE_ALREADY_PRESENT`

*Defined as:* `26`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L141)

Node already present.

---

### `XMLSEC_ERRORS_R_UNEXPECTED_NODE`

*Defined as:* `27`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L146)

Unexpected node.

---

### `XMLSEC_ERRORS_R_NODE_NOT_FOUND`

*Defined as:* `28`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L151)

Node not found.

---

### `XMLSEC_ERRORS_R_INVALID_TRANSFORM`

*Defined as:* `31`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L156)

This transform is invalid.

---

### `XMLSEC_ERRORS_R_INVALID_TRANSFORM_KEY`

*Defined as:* `32`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L161)

Key is invalid for this transform.

---

### `XMLSEC_ERRORS_R_INVALID_URI_TYPE`

*Defined as:* `33`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L166)

Invalid URI type.

---

### `XMLSEC_ERRORS_R_TRANSFORM_SAME_DOCUMENT_REQUIRED`

*Defined as:* `34`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L172)

The transform requires the same document as context.

The transform requires the input document to be the same as context.

---

### `XMLSEC_ERRORS_R_TRANSFORM_DISABLED`

*Defined as:* `35`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L177)

The transform is disabled.

---

### `XMLSEC_ERRORS_R_INVALID_ALGORITHM`

*Defined as:* `36`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L182)

Invalid or unsupported algorithm.

---

### `XMLSEC_ERRORS_R_INVALID_KEY_DATA`

*Defined as:* `41`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L187)

Key data is invalid.

---

### `XMLSEC_ERRORS_R_KEY_DATA_NOT_FOUND`

*Defined as:* `42`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L192)

Key data is not found.

---

### `XMLSEC_ERRORS_R_KEY_DATA_ALREADY_EXIST`

*Defined as:* `43`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L197)

The key data already exists.

---

### `XMLSEC_ERRORS_R_INVALID_KEY_DATA_SIZE`

*Defined as:* `44`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L202)

Invalid key size.

---

### `XMLSEC_ERRORS_R_KEY_NOT_FOUND`

*Defined as:* `45`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L207)

Key not found.

---

### `XMLSEC_ERRORS_R_KEYDATA_DISABLED`

*Defined as:* `46`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L212)

The key data type is disabled.

---

### `XMLSEC_ERRORS_R_MAX_RETRIEVALS_LEVEL`

*Defined as:* `51`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L217)

Max allowed retrievals level reached.

---

### `XMLSEC_ERRORS_R_MAX_RETRIEVAL_TYPE_MISMATCH`

*Defined as:* `52`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L223)

Key data type mismatch in dsig:RetrievalMethod node.

The retrieved key data type does not match the one specified in the <dsig:RetrievalMethod/> node.

---

### `XMLSEC_ERRORS_R_MAX_KEYINFOREFERENCE_LEVEL`

*Defined as:* `51`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L228)

Max allowed KeyInfoReference level reached.

---

### `XMLSEC_ERRORS_R_MAX_ENCKEY_LEVEL`

*Defined as:* `61`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L233)

Max EncryptedKey level reached.

---

### `XMLSEC_ERRORS_R_CERT_VERIFY_FAILED`

*Defined as:* `71`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L238)

Certificate verification failed.

---

### `XMLSEC_ERRORS_R_CERT_NOT_FOUND`

*Defined as:* `72`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L243)

Requested certificate is not found.

---

### `XMLSEC_ERRORS_R_CERT_REVOKED`

*Defined as:* `73`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L248)

The certificate is revoked.

---

### `XMLSEC_ERRORS_R_CERT_ISSUER_FAILED`

*Defined as:* `74`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L253)

Failed to get certificate issuer.

---

### `XMLSEC_ERRORS_R_CERT_NOT_YET_VALID`

*Defined as:* `75`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L258)

"Not valid before" verification failed.

---

### `XMLSEC_ERRORS_R_CERT_HAS_EXPIRED`

*Defined as:* `76`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L263)

"Not valid after" verification failed.

---

### `XMLSEC_ERRORS_R_CRL_VERIFY_FAILED`

*Defined as:* `77`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L268)

CRL verification failed.

---

### `XMLSEC_ERRORS_R_CRL_NOT_YET_VALID`

*Defined as:* `78`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L273)

"Last update" CRL verification failed.

---

### `XMLSEC_ERRORS_R_CRL_HAS_EXPIRED`

*Defined as:* `79`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L278)

"Next update" verification failed.

---

### `XMLSEC_ERRORS_R_DSIG_NO_REFERENCES`

*Defined as:* `81`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L283)

The <dsig:Reference/> nodes not found.

---

### `XMLSEC_ERRORS_R_DSIG_INVALID_REFERENCE`

*Defined as:* `82`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L288)

The <dsig:Reference/> validation failed.

---

### `XMLSEC_ERRORS_R_ASSERTION`

*Defined as:* `100`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L293)

Invalid assertion.

---

### `XMLSEC_ERROR_R_CAST_IMPOSSIBLE`

*Defined as:* `101`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L298)

Impossible to cast from one type to another.

---

### `XMLSEC_ERRORS_MAX_NUMBER`

*Defined as:* `256`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L303)

The maximum xmlsec errors number.

---

### `__XMLSEC_FUNCTION__`

*Defined as:* `__func__`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L360)

The current function name (compiler-specific).

---

### `XMLSEC_ERRORS_HERE`

*Defined as:* `__FILE__,__LINE__,__XMLSEC_FUNCTION__`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L373)

The macro specifying the error location (file, line, function) for `xmlSecError()`.

defined(**XMLSEC_FUNCTION**)

The macro that specifies the location (file, line and function) for the `xmlSecError()` function.

---

### `XMLSEC_ERRORS_PRINTF_ATTRIBUTE`

*Defined as:* `__attribute__ ((format (printf, 7, 8)))`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L379)

Printf-style format-string attribute for `xmlSecError()` (GCC/Clang only).

Printf-style format-string attribute for the `xmlSecError()` function (GCC/Clang only; empty on other compilers).

---

### `xmlSecErrorsSafeString`

*Defined as:* `(((str) != NULL) ? ((const char*)(str)) : (const char*)"NULL")`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L388)

Macro. Returns `str` if it is not NULL or pointer to "NULL" otherwise.

**Parameters:**

- `str` — the string.

---

### `XMLSEC_ERRORS_NO_MESSAGE`

*Defined as:* `" "`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L394)

Empty error message " ".

---

### `xmlSecAssert`

*Defined as:* `if(!( p ) ) { \
            xmlSecError(XMLSEC_ERRORS_HERE, \
                        NULL, \
                        #p, \
                        XMLSEC_ERRORS_R_ASSERTION, \
                        XMLSEC_ERRORS_NO_MESSAGE); \
            return; \
        }`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L414)

Macro. Verifies that `is` true and calls return() otherwise.

**Parameters:**

- `p` — the expression.

---

### `xmlSecAssert2`

*Defined as:* `if(!( p ) ) { \
            xmlSecError(XMLSEC_ERRORS_HERE, \
                        NULL, \
                        #p, \
                        XMLSEC_ERRORS_R_ASSERTION, \
                        XMLSEC_ERRORS_NO_MESSAGE); \
            return(ret); \
        }`

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L429)

Macro. Verifies that `is` true and calls return(`ret`) otherwise.

**Parameters:**

- `p` — the expression.
- `ret` — the return value.

---

## Typedefs

### `xmlSecErrorsCallback`

```c
typedef void(* xmlSecErrorsCallback) (const char *file, int line, const char *func, const char *errorObject, const char *errorSubject, int reason, const char *msg))(const char *file, int line, const char *func, const char *errorObject, const char *errorSubject, int reason, const char *msg);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L321)

The errors reporting callback function.

**Parameters:**

- `line` — the error location line number (**LINE** macro).
- `func` — the error location function name (**func** macro).
- `errorObject` — the error specific error object (e.g. transform, key data, etc).
- `errorSubject` — the error specific error subject.
- `reason` — the error code.
- `msg` — the additional error message.

---

## Functions

### `xmlSecErrorsInit`

```c
void xmlSecErrorsInit(void);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L330)

Initializes the errors reporting.

Initializes the errors reporting. It is called from `xmlSecInit` function. and applications must not call this function directly.

---

### `xmlSecErrorsShutdown`

```c
void xmlSecErrorsShutdown(void);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L331)

Cleanups the errors reporting.

Cleanups the errors reporting. It is called from `xmlSecShutdown` function. and applications must not call this function directly.

---

### `xmlSecErrorsSetCallback`

```c
void xmlSecErrorsSetCallback(xmlSecErrorsCallback callback);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L332)

Sets the errors callback function.

Sets the errors callback function to `callback` that will be called every time an error occurs. 

**Parameters:**

- `callback` — the new errors callback function.

---

### `xmlSecErrorsDefaultCallback`

```c
void xmlSecErrorsDefaultCallback(const char *file, int line, const char *func, const char *errorObject, const char *errorSubject, int reason, const char *msg);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L333)

The default error reporting callback using LibXML.

The default error reporting callback that utilizes LibXML error reporting xmlGenericError function. 

**Parameters:**

- `file` — the error location file name (**FILE** macro).
- `line` — the error location line number (**LINE** macro).
- `func` — the error location function name (**FUNCTION** macro).
- `errorObject` — the error specific error object
- `errorSubject` — the error specific error subject.
- `reason` — the error code.S
- `msg` — the additional error message.

---

### `xmlSecErrorsDefaultCallbackEnableOutput`

```c
void xmlSecErrorsDefaultCallbackEnableOutput(int enabled);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L340)

Enables or disables output from the default errors callback.

Enables or disables calling LibXML2 callback from the default errors callback. 

**Parameters:**

- `enabled` — the flag.

---

### `xmlSecErrorsGetCode`

```c
int xmlSecErrorsGetCode(xmlSecSize pos);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L343)

Gets the known error code at position `pos`.

**Parameters:**

- `pos` — the error position.


**Returns:** the known error code or 0 if `pos` is greater than total number of known error codes.

---

### `xmlSecErrorsGetMsg`

```c
const char * xmlSecErrorsGetMsg(xmlSecSize pos);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L344)

Gets the known error message at position `pos`.

**Parameters:**

- `pos` — the error position.


**Returns:** the known error message or NULL if `pos` is greater than total number of known error codes.

---

### `xmlSecErrorsPrintCryptoLibraryLogOnExitSet`

```c
void xmlSecErrorsPrintCryptoLibraryLogOnExitSet(int enabled);
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L347)

Enables or disables the crypto library error log dump on exit.

Enables or disables the crypto library error log dump on exit (only supported by OpenSSL). 

**Parameters:**

- `enabled` — the flag

---

### `xmlSecError`

```c
void xmlSecError(const char *file, int line, const char *func, const char *errorObject, const char *errorSubject, int reason, const char *msg,...) XMLSEC_ERRORS_PRINTF_ATTRIBUTE;
```

*Source:* [include/xmlsec/errors.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/errors.h#L397)

Reports an error to the error callback.

Reports an error to the default (`xmlSecErrorsDefaultCallback`) or application specific callback installed using `xmlSecErrorsSetCallback` function. 

**Parameters:**

- `file` — the error location filename (**FILE**).
- `line` — the error location line number (**LINE**).
- `func` — the error location function (**FUNCTION**).
- `errorObject` — the error specific error object (e.g. transform, key data, etc).
- `errorSubject` — the error specific error subject (e.g. failed function name).
- `reason` — the error code.
- `msg` — the error message in printf format.
- `...` — the parameters for the `msg`.

---
