json_print_error_message Subroutine

private subroutine json_print_error_message(json, io_unit)

Print any error message, and then clear the exceptions.

Note

This routine is used by the unit tests. It was originally in json_example.f90, and was moved here 2/26/2015 by Izaak Beekman.

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
class(json_core), intent(inout) :: json
integer, intent(in), optional :: io_unit

unit number for printing error message


Calls

proc~~json_print_error_message~~CallsGraph proc~json_print_error_message json_value_module::json_core%json_print_error_message proc~json_check_for_errors json_value_module::json_core%json_check_for_errors proc~json_print_error_message->proc~json_check_for_errors proc~json_clear_exceptions json_value_module::json_core%json_clear_exceptions proc~json_print_error_message->proc~json_clear_exceptions

Called by

proc~~json_print_error_message~~CalledByGraph proc~json_print_error_message json_value_module::json_core%json_print_error_message proc~json_file_print_error_message json_file_module::json_file%json_file_print_error_message proc~json_file_print_error_message->proc~json_print_error_message

Source Code

    subroutine json_print_error_message(json,io_unit)

    implicit none

    class(json_core),intent(inout) :: json
    integer, intent(in), optional  :: io_unit  !! unit number for
                                               !! printing error message

    character(kind=CK,len=:),allocatable :: error_msg  !! error message
    logical :: status_ok !! false if there were any errors thrown

    !get error message:
    call json%check_for_errors(status_ok, error_msg)

    !print it if there is one:
    if (.not. status_ok) then
        if (present(io_unit)) then
            write(io_unit,'(A)') error_msg
        else
            write(output_unit,'(A)') error_msg
        end if
        deallocate(error_msg)
        call json%clear_exceptions()
    end if

    end subroutine json_print_error_message