json_print_error_message Subroutine

private subroutine json_print_error_message(json, io_unit)

Print any error message, and then clear the exceptions.

Arguments

TypeIntentOptionalAttributesName
class(json_core), intent(inout) :: json
integer, intent(in), optional :: io_unit

unit number for printing error message


Contents


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