| 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 Stack trace support |
||
| integer, | public | :: | stack_depth | = | 0 |
Current stack depth |
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 |
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 |
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 |
type :: error_t integer :: code = SUCCESS !! Error code (0 = no error) character(len=:), allocatable :: message !! Error message !! Stack trace support integer :: stack_depth = 0 !! Current stack depth character(len=MAX_LOCATION_LEN) :: call_stack(MAX_STACK_DEPTH) !! Call locations contains procedure :: has_error => error_has_error procedure :: set => error_set procedure :: clear => error_clear procedure :: get_code => error_get_code procedure :: get_message => error_get_message procedure :: add_context => error_add_context procedure :: get_full_trace => error_get_full_trace procedure :: print_trace => error_print_trace end type error_t