json_check_for_errors Subroutine

public subroutine json_check_for_errors(status_ok, error_msg)

Arguments

Type IntentOptional AttributesName
logical(kind=LK), intent(out) :: status_ok

true if there were no errors

character(kind=CK,len=:), intent(out), allocatable:: error_msg

the error message (if there were errors)

Description

Retrieve error code from the module. This should be called after json_parse to check for errors. If an error is thrown, before using the module again, json_initialize should be called to clean up before it is used again.

Example

     type(json_file) :: json
     logical :: status_ok
     character(kind=CK,len=:),allocatable :: error_msg
     call json%load_file(filename='myfile.json')
     call json_check_for_errors(status_ok, error_msg)
     if (.not. status_ok) then
         write(*,*) 'Error: '//error_msg
         call json_clear_exceptions()
         call json%destroy()
     end if

See also

Called By

proc~~json_check_for_errors~~CalledByGraph proc~json_check_for_errors json_check_for_errors proc~json_print_error_message json_print_error_message proc~json_print_error_message->proc~json_check_for_errors proc~test_7 test_7 proc~test_7->proc~json_print_error_message proc~test_9 test_9 proc~test_9->proc~json_print_error_message proc~test_2 test_2 proc~test_2->proc~json_print_error_message proc~add_variables_to_input add_variables_to_input proc~test_2->proc~add_variables_to_input none~check_errors check_errors none~check_errors->proc~json_print_error_message proc~test_3 test_3 proc~test_3->proc~json_print_error_message proc~test_8 test_8 proc~test_8->proc~json_print_error_message proc~test_13 test_13 proc~test_13->proc~json_print_error_message proc~add_variables_to_input->proc~json_print_error_message proc~test_1 test_1 proc~test_1->proc~json_print_error_message proc~test_10 test_10 proc~test_10->proc~json_print_error_message proc~test_5 test_5 proc~test_5->proc~json_print_error_message proc~test_14 test_14 proc~test_14->proc~json_print_error_message proc~test_6 test_6 proc~test_6->proc~json_print_error_message proc~test_11 test_11 proc~test_11->proc~json_print_error_message proc~test_4 test_4 proc~test_4->proc~json_print_error_message program~jf_test_7 jf_test_7 program~jf_test_7->proc~test_7 program~jf_test_9 jf_test_9 program~jf_test_9->proc~test_9 program~jf_test_2 jf_test_2 program~jf_test_2->proc~test_2 proc~test_12 test_12 proc~test_12->none~check_errors program~jf_test_12 jf_test_12 program~jf_test_12->proc~test_12 program~jf_test_3 jf_test_3 program~jf_test_3->proc~test_3 program~jf_test_8 jf_test_8 program~jf_test_8->proc~test_8 program~jf_test_13 jf_test_13 program~jf_test_13->proc~test_13 program~jf_test_1 jf_test_1 program~jf_test_1->proc~test_1 program~jf_test_10 jf_test_10 program~jf_test_10->proc~test_10 program~jf_test_5 jf_test_5 program~jf_test_5->proc~test_5 program~jf_test_14 jf_test_14 program~jf_test_14->proc~test_14 program~jf_test_6 jf_test_6 program~jf_test_6->proc~test_6 program~jf_test_11 jf_test_11 program~jf_test_11->proc~test_11 program~jf_test_4 jf_test_4 program~jf_test_4->proc~test_4
Help

Source Code

    subroutine json_check_for_errors(status_ok, error_msg)

    implicit none

    logical(LK),intent(out) :: status_ok !! true if there were no errors
    character(kind=CK,len=:),allocatable,intent(out) :: error_msg !! the error message (if there were errors)

    status_ok = .not. exception_thrown

    if (.not. status_ok) then
        if (allocated(err_message)) then
            error_msg = err_message
        else
            error_msg = 'Error: json_initialize() must be called first to initialize the module.'
        end if
    else
        error_msg = ''
    end if

    end subroutine json_check_for_errors