tomlf_error Module

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.



Variables

Type Visibility Attributes Name Initial
type(enum_stat), public, parameter :: toml_stat = enum_stat()

Actual enumerator for return states

Name Description
success Operation completed successfully
fatal Internal error or undefined error state
duplicate_key Duplicate key encountered in table
type_mismatch Incorrect type when reading a value
conversion_error Error when converting or downcasting a value
missing_key Requested key not present in table

Derived Types

type, public ::  toml_error

Error message produced by TOML-Fortran

Components

Type Visibility Attributes Name Initial
character(kind=tfc, len=:), public, allocatable :: message

Payload of the error

integer, public :: stat = toml_stat%fatal

Error code


Subroutines

public subroutine make_error(error, message, stat)

Create new error message

Arguments

Type IntentOptional 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