Error handling for TOML Fortran
This module provides the toml_error type for error reporting and the toml_stat enumerator for status codes returned by various TOML Fortran procedures.
## Error Handling
Most parsing and access functions accept an optional error argument
of type toml_error. If an error occurs, this will be allocated
and contain a descriptive message:
type(toml_error), allocatable :: error
call toml_load(table, "config.toml", error=error)
if (allocated(error)) print '(a)', error%message
## Status Codes
The toml_stat enumerator provides named constants for common
error conditions like toml_stat%duplicate_key or toml_stat%type_mismatch.
| Type | Visibility | Attributes | Name | Initial | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| type(enum_stat), | public, | parameter | :: | toml_stat | = | enum_stat() |
Actual enumerator for return states
|
Error message produced by TOML-Fortran
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(kind=tfc, len=:), | public, | allocatable | :: | message |
Payload of the error |
||
| integer, | public | :: | stat | = | toml_stat%fatal |
Error code |
Create new error message
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(toml_error), | intent(out), | allocatable | :: | error |
Error report |
|
| character(kind=tfc, len=*), | intent(in) | :: | message |
Message for the error |
||
| integer, | intent(in), | optional | :: | stat |
Status code |