Print any error message, and then clear the exceptions.
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 | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
integer, | intent(in), | optional | :: | io_unit |
subroutine json_print_error_message(json,io_unit)
implicit none
class(json_core),intent(inout) :: json
integer, intent(in), optional :: io_unit
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