Map an error code to a human-readable name
Usage: print *, code_to_string(ERROR_IO) ! “ERROR_IO”
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | code |
pure function code_to_string(code) result(name) !! Map an error code to a human-readable name !! !! Usage: print *, code_to_string(ERROR_IO) ! "ERROR_IO" integer(default_int), intent(in) :: code character(len=:), allocatable :: name select case (code) case (SUCCESS) name = "SUCCESS" case (ERROR_GENERIC) name = "ERROR_GENERIC" case (ERROR_IO) name = "ERROR_IO" case (ERROR_PARSE) name = "ERROR_PARSE" case (ERROR_VALIDATION) name = "ERROR_VALIDATION" case (ERROR_ALLOC) name = "ERROR_ALLOC" case default name = "UNKNOWN" end select end function code_to_string