Throw an exception in the json_core. This routine sets the error flag, and prevents any subsequent routine from doing anything, until json_clear_exceptions is called.
If is_verbose
is true, this will also print a
traceback if the Intel compiler is used.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
character(kind=CK,len=*), | intent(in) | :: | msg | the error message |
subroutine json_throw_exception(json,msg)
#ifdef __INTEL_COMPILER
use ifcore, only: tracebackqq
#endif
implicit none
class(json_core),intent(inout) :: json
character(kind=CK,len=*),intent(in) :: msg !! the error message
json%exception_thrown = .true.
json%err_message = trim(msg)
if (json%is_verbose) then
write(output_unit,'(A)') '***********************'
write(output_unit,'(A)') 'JSON-Fortran Exception: '//trim(msg)
!call backtrace() ! gfortran (use -fbacktrace -fall-intrinsics flags)
#ifdef __INTEL_COMPILER
call tracebackqq(user_exit_code=-1) ! print a traceback and return
#endif
write(output_unit,'(A)') '***********************'
end if
end subroutine json_throw_exception