runner_error Subroutine

public subroutine runner_error(pattern, text, code, result)

This subroutine runs is_valid_error function and prints its result.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pattern
character(len=*), intent(in) :: text
integer, intent(in) :: code
logical, intent(inout) :: result

Source Code

   subroutine runner_error(pattern, text, code, result)
      use :: forgex_error_m
      implicit none
      character(*), intent(in) :: pattern, text
      integer, intent(in) :: code
      logical, intent(inout) :: result
      
      character(10) :: cache
      character(:), allocatable :: fmt, fmt_with_code
      logical :: res
      integer :: returned_code, width

      cache = ''
      width = max(len_trim(pattern), 15)
      write(cache, '(i0)') width
      fmt = '(a, a'//trim(adjustl(cache))//', a)'
      fmt_with_code = '(a, a'//trim(adjustl(cache))//', a, i3)'

      res = is_valid__error(pattern, text, code, returned_code)

      if (res) then
#ifndef FAILED
         write(output_unit, fmt) 'result(error): Success: ', pattern, ': "'//trim(get_error_message(returned_code))//'" '
#endif
      else
         write(error_unit, fmt_with_code) 'result(error): FAILED:  ', pattern, &
             ': "'//trim(get_error_message(returned_code))//'" error code =', returned_code
      end if

      result = result .and. res

   end subroutine runner_error