json_failed Function

private pure function json_failed(json) result(failed)

Logical function to indicate if an exception has been thrown in a json_core.

Example

    type(json_core) :: json
    type(json_value),pointer :: p
    logical :: status_ok
    character(len=:),allocatable :: error_msg
    call json%load(filename='myfile.json',p)
    if (json%failed()) then
        call json%check_for_errors(status_ok, error_msg)
        write(*,*) 'Error: '//error_msg
        call json%clear_exceptions()
        call json%destroy(p)
    end if

Note that json_file contains a wrapper for this routine, which is used like:

    type(json_file) :: f
    logical :: status_ok
    character(len=:),allocatable :: error_msg
    call f%load(filename='myfile.json')
    if (f%failed()) then
        call f%check_for_errors(status_ok, error_msg)
        write(*,*) 'Error: '//error_msg
        call f%clear_exceptions()
        call f%destroy()
    end if

See also

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
class(json_core), intent(in) :: json

Return Value logical(kind=LK)

will be true if an exception has been thrown.


Called by

proc~~json_failed~~CalledByGraph proc~json_failed json_core%json_failed proc~assign_json_file_to_string json_file%assign_json_file_to_string proc~assign_json_file_to_string->proc~json_failed proc~json_value_to_string json_core%json_value_to_string proc~assign_json_file_to_string->proc~json_value_to_string proc~assign_string_to_json_file json_file%assign_string_to_json_file proc~assign_string_to_json_file->proc~json_failed proc~json_file_failed json_file%json_file_failed proc~json_file_failed->proc~json_failed proc~json_file_update_integer json_file%json_file_update_integer proc~json_file_update_integer->proc~json_failed proc~json_file_update_logical json_file%json_file_update_logical proc~json_file_update_logical->proc~json_failed proc~json_file_update_real json_file%json_file_update_real proc~json_file_update_real->proc~json_failed proc~json_file_update_string json_file%json_file_update_string proc~json_file_update_string->proc~json_failed proc~json_value_print json_core%json_value_print proc~json_value_print->proc~json_failed proc~json_value_print->proc~json_value_print proc~json_value_validate json_core%json_value_validate proc~json_value_validate->proc~json_failed none~update~2 json_file%update none~update~2->proc~json_file_update_integer none~update~2->proc~json_file_update_logical none~update~2->proc~json_file_update_real none~update~2->proc~json_file_update_string proc~json_file_update_real32 json_file%json_file_update_real32 none~update~2->proc~json_file_update_real32 proc~json_file_move_pointer json_file%json_file_move_pointer proc~json_file_move_pointer->proc~json_file_failed proc~json_print_to_unit json_core%json_print_to_unit proc~json_print_to_unit->proc~json_value_print proc~json_value_to_string->proc~json_value_print proc~wrap_assign_string_to_json_file wrap_assign_string_to_json_file proc~wrap_assign_string_to_json_file->proc~assign_string_to_json_file proc~json_file_print_to_string json_file%json_file_print_to_string proc~json_file_print_to_string->proc~json_value_to_string proc~json_file_update_real32->none~update~2 proc~json_file_update_string_name_ascii json_file_update_string_name_ascii proc~json_file_update_string_name_ascii->none~update~2 proc~json_file_update_string_val_ascii json_file_update_string_val_ascii proc~json_file_update_string_val_ascii->none~update~2 proc~wrap_json_file_update_integer wrap_json_file_update_integer proc~wrap_json_file_update_integer->none~update~2 proc~wrap_json_file_update_logical wrap_json_file_update_logical proc~wrap_json_file_update_logical->none~update~2 proc~wrap_json_file_update_real wrap_json_file_update_real proc~wrap_json_file_update_real->none~update~2 proc~wrap_json_file_update_real32 wrap_json_file_update_real32 proc~wrap_json_file_update_real32->none~update~2 proc~wrap_json_file_update_string wrap_json_file_update_string proc~wrap_json_file_update_string->none~update~2

Source Code

    pure function json_failed(json) result(failed)

    implicit none

    class(json_core),intent(in) :: json
    logical(LK)                 :: failed  !! will be true if an exception
                                           !! has been thrown.

    failed = json%exception_thrown

    end function json_failed