Error codes
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | ERROR_GENERIC | = | 1 | |
| integer, | public, | parameter | :: | ERROR_IO | = | 2 | |
| integer, | public, | parameter | :: | ERROR_PARSE | = | 3 | |
| integer, | public, | parameter | :: | ERROR_VALIDATION | = | 4 |
Stack trace configuration |
| integer, | public, | parameter | :: | SUCCESS | = | 0 | |
| integer, | private, | parameter | :: | MAX_LOCATION_LEN | = | 128 |
Unified error type with stack trace support |
| integer, | private, | parameter | :: | MAX_STACK_DEPTH | = | 20 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=MAX_LOCATION_LEN), | public | :: | call_stack(MAX_STACK_DEPTH) |
Call locations |
|||
| integer, | public | :: | code | = | SUCCESS |
Error code (0 = no error) |
|
| character(len=:), | public, | allocatable | :: | message |
Error message |
||
| integer, | public | :: | stack_depth | = | 0 |
Current stack depth |
| procedure, public :: add_context => error_add_context | |
| procedure, public :: clear => error_clear | |
| procedure, public :: get_code => error_get_code | |
| procedure, public :: get_full_trace => error_get_full_trace | |
| procedure, public :: get_message => error_get_message | |
| procedure, public :: has_error => error_has_error | |
| procedure, public :: print_trace => error_print_trace | |
| procedure, public :: set => error_set |
Get the error code
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(in) | :: | this |
Get complete error message with stack trace Returns a multi-line string with error and call stack
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(in) | :: | this |
Get the error message (without stack trace)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(in) | :: | this |
Check if an error is set
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(in) | :: | this |
Add a call location to the stack trace Typically called when propagating errors upward
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(inout) | :: | this | |||
| character(len=*), | intent(in) | :: | location |
Clear the error state and stack trace
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(inout) | :: | this |
Print error with stack trace to specified unit If unit not specified, prints to stdout (unit 6)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(in) | :: | this | |||
| integer, | intent(in), | optional | :: | unit |