errored Subroutine

private subroutine errored(self, error, pref, switch, val_str, log_value)

Trig error occurence and print meaningful message.

Type Bound

command_line_argument

Arguments

Type IntentOptional Attributes Name
class(command_line_argument), intent(inout) :: self

CLA data.

integer(kind=I4P), intent(in) :: error

Error occurred.

character(len=*), intent(in), optional :: pref

Prefixing string.

character(len=*), intent(in), optional :: switch

CLA switch name.

character(len=*), intent(in), optional :: val_str

Value string.

character(len=*), intent(in), optional :: log_value

Logical value to be casted.


Calls

proc~~errored~2~~CallsGraph proc~errored~2 flap_command_line_argument_t::command_line_argument%errored interface~colorize face::colorize proc~errored~2->interface~colorize proc~print_error_message flap_object_t::object%print_error_message proc~errored~2->proc~print_error_message str str proc~errored~2->str proc~colorize_default face::colorize_default interface~colorize->proc~colorize_default proc~color_index face::color_index proc~colorize_default->proc~color_index proc~style_index face::style_index proc~colorize_default->proc~style_index proc~upper face::upper proc~colorize_default->proc~upper

Called by

proc~~errored~2~~CalledByGraph proc~errored~2 flap_command_line_argument_t::command_line_argument%errored proc~check_action_consistency flap_command_line_argument_t::command_line_argument%check_action_consistency proc~check_action_consistency->proc~errored~2 proc~check_choices flap_command_line_argument_t::command_line_argument%check_choices proc~check_choices->proc~errored~2 proc~check_envvar_consistency flap_command_line_argument_t::command_line_argument%check_envvar_consistency proc~check_envvar_consistency->proc~errored~2 proc~check_list_size flap_command_line_argument_t::command_line_argument%check_list_size proc~check_list_size->proc~errored~2 proc~check_m_exclude_consistency flap_command_line_argument_t::command_line_argument%check_m_exclude_consistency proc~check_m_exclude_consistency->proc~errored~2 proc~check_named_consistency flap_command_line_argument_t::command_line_argument%check_named_consistency proc~check_named_consistency->proc~errored~2 proc~check_optional_consistency flap_command_line_argument_t::command_line_argument%check_optional_consistency proc~check_optional_consistency->proc~errored~2 proc~check_positional_consistency flap_command_line_argument_t::command_line_argument%check_positional_consistency proc~check_positional_consistency->proc~errored~2 proc~get_cla flap_command_line_argument_t::command_line_argument%get_cla proc~get_cla->proc~errored~2 proc~get_cla->proc~check_choices proc~get_cla_from_buffer flap_command_line_argument_t::command_line_argument%get_cla_from_buffer proc~get_cla->proc~get_cla_from_buffer proc~is_required_passed~2 flap_command_line_argument_t::command_line_argument%is_required_passed proc~get_cla->proc~is_required_passed~2 proc~get_cla_from_buffer->proc~errored~2 proc~get_cla_list flap_command_line_argument_t::command_line_argument%get_cla_list proc~get_cla_list->proc~errored~2 proc~get_cla_list_from_buffer flap_command_line_argument_t::command_line_argument%get_cla_list_from_buffer proc~get_cla_list->proc~get_cla_list_from_buffer proc~get_cla_list->proc~is_required_passed~2 proc~get_cla_list_from_buffer->proc~errored~2 proc~get_cla_list_from_buffer->proc~check_choices proc~get_cla_list_varying_char flap_command_line_argument_t::command_line_argument%get_cla_list_varying_char proc~get_cla_list_varying_char->proc~errored~2 proc~get_cla_list_varying_char->proc~check_list_size proc~get_cla_list_varying_char->proc~is_required_passed~2 proc~get_cla_list_varying_i1p flap_command_line_argument_t::command_line_argument%get_cla_list_varying_I1P proc~get_cla_list_varying_i1p->proc~errored~2 proc~get_cla_list_varying_i1p->proc~check_list_size proc~get_cla_list_varying_i1p->proc~is_required_passed~2 proc~get_cla_list_varying_i2p flap_command_line_argument_t::command_line_argument%get_cla_list_varying_I2P proc~get_cla_list_varying_i2p->proc~errored~2 proc~get_cla_list_varying_i2p->proc~check_list_size proc~get_cla_list_varying_i2p->proc~is_required_passed~2 proc~get_cla_list_varying_i4p flap_command_line_argument_t::command_line_argument%get_cla_list_varying_I4P proc~get_cla_list_varying_i4p->proc~errored~2 proc~get_cla_list_varying_i4p->proc~check_list_size proc~get_cla_list_varying_i4p->proc~is_required_passed~2 proc~get_cla_list_varying_i8p flap_command_line_argument_t::command_line_argument%get_cla_list_varying_I8P proc~get_cla_list_varying_i8p->proc~errored~2 proc~get_cla_list_varying_i8p->proc~check_list_size proc~get_cla_list_varying_i8p->proc~is_required_passed~2 proc~get_cla_list_varying_logical flap_command_line_argument_t::command_line_argument%get_cla_list_varying_logical proc~get_cla_list_varying_logical->proc~errored~2 proc~get_cla_list_varying_logical->proc~check_list_size proc~get_cla_list_varying_logical->proc~is_required_passed~2 proc~get_cla_list_varying_r16p flap_command_line_argument_t::command_line_argument%get_cla_list_varying_R16P proc~get_cla_list_varying_r16p->proc~errored~2 proc~get_cla_list_varying_r16p->proc~check_list_size proc~get_cla_list_varying_r16p->proc~is_required_passed~2 proc~get_cla_list_varying_r4p flap_command_line_argument_t::command_line_argument%get_cla_list_varying_R4P proc~get_cla_list_varying_r4p->proc~errored~2 proc~get_cla_list_varying_r4p->proc~check_list_size proc~get_cla_list_varying_r4p->proc~is_required_passed~2 proc~get_cla_list_varying_r8p flap_command_line_argument_t::command_line_argument%get_cla_list_varying_R8P proc~get_cla_list_varying_r8p->proc~errored~2 proc~get_cla_list_varying_r8p->proc~check_list_size proc~get_cla_list_varying_r8p->proc~is_required_passed~2 proc~is_required_passed~2->proc~errored~2 proc~is_required_val_passed flap_command_line_argument_t::is_required_val_passed proc~is_required_val_passed->proc~errored~2 proc~raise_error_duplicated_clas flap_command_line_argument_t::command_line_argument%raise_error_duplicated_clas proc~raise_error_duplicated_clas->proc~errored~2 proc~raise_error_m_exclude~2 flap_command_line_argument_t::command_line_argument%raise_error_m_exclude proc~raise_error_m_exclude~2->proc~errored~2 proc~raise_error_nargs_insufficient flap_command_line_argument_t::command_line_argument%raise_error_nargs_insufficient proc~raise_error_nargs_insufficient->proc~errored~2 proc~raise_error_switch_unknown flap_command_line_argument_t::command_line_argument%raise_error_switch_unknown proc~raise_error_switch_unknown->proc~errored~2 proc~raise_error_value_missing flap_command_line_argument_t::command_line_argument%raise_error_value_missing proc~raise_error_value_missing->proc~errored~2 none~get flap_command_line_argument_t::command_line_argument%get none~get->proc~get_cla none~get->proc~get_cla_list none~get_varying flap_command_line_argument_t::command_line_argument%get_varying none~get_varying->proc~get_cla_list_varying_char none~get_varying->proc~get_cla_list_varying_i1p none~get_varying->proc~get_cla_list_varying_i2p none~get_varying->proc~get_cla_list_varying_i4p none~get_varying->proc~get_cla_list_varying_i8p none~get_varying->proc~get_cla_list_varying_logical none~get_varying->proc~get_cla_list_varying_r4p none~get_varying->proc~get_cla_list_varying_r8p proc~check_m_exclusive flap_command_line_arguments_group_t::command_line_arguments_group%check_m_exclusive proc~check_m_exclusive->proc~raise_error_m_exclude~2 proc~check~2 flap_command_line_argument_t::command_line_argument%check proc~check~2->proc~check_action_consistency proc~check~2->proc~check_envvar_consistency proc~check~2->proc~check_m_exclude_consistency proc~check~2->proc~check_named_consistency proc~check~2->proc~check_optional_consistency proc~check~2->proc~check_positional_consistency proc~is_required_passed flap_command_line_arguments_group_t::command_line_arguments_group%is_required_passed proc~is_required_passed->proc~is_required_passed~2 proc~parse flap_command_line_arguments_group_t::command_line_arguments_group%parse proc~parse->proc~raise_error_duplicated_clas proc~parse->proc~raise_error_nargs_insufficient proc~parse->proc~raise_error_switch_unknown proc~parse->proc~raise_error_value_missing proc~parse->proc~check_m_exclusive proc~add~2 flap_command_line_interface_t::command_line_interface%add proc~add~2->proc~check~2 proc~get_cla_list_varying_char~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_char proc~get_cla_list_varying_char~2->none~get_varying proc~parse~2 flap_command_line_interface_t::command_line_interface%parse proc~get_cla_list_varying_char~2->proc~parse~2 proc~get_cla_list_varying_i1p~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_I1P proc~get_cla_list_varying_i1p~2->none~get_varying proc~get_cla_list_varying_i1p~2->proc~parse~2 proc~get_cla_list_varying_i2p~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_I2P proc~get_cla_list_varying_i2p~2->none~get_varying proc~get_cla_list_varying_i2p~2->proc~parse~2 proc~get_cla_list_varying_i4p~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_I4P proc~get_cla_list_varying_i4p~2->none~get_varying proc~get_cla_list_varying_i4p~2->proc~parse~2 proc~get_cla_list_varying_i8p~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_I8P proc~get_cla_list_varying_i8p~2->none~get_varying proc~get_cla_list_varying_i8p~2->proc~parse~2 proc~get_cla_list_varying_logical~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_logical proc~get_cla_list_varying_logical~2->none~get_varying proc~get_cla_list_varying_logical~2->proc~parse~2 proc~get_cla_list_varying_r16p~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_R16P proc~get_cla_list_varying_r16p~2->none~get_varying proc~get_cla_list_varying_r16p~2->proc~parse~2 proc~get_cla_list_varying_r4p~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_R4P proc~get_cla_list_varying_r4p~2->none~get_varying proc~get_cla_list_varying_r4p~2->proc~parse~2 proc~get_cla_list_varying_r8p~2 flap_command_line_interface_t::command_line_interface%get_cla_list_varying_R8P proc~get_cla_list_varying_r8p~2->none~get_varying proc~get_cla_list_varying_r8p~2->proc~parse~2 proc~get_cla_list~2 flap_command_line_interface_t::command_line_interface%get_cla_list proc~get_cla_list~2->none~get proc~get_cla_list~2->proc~parse~2 proc~get_cla~2 flap_command_line_interface_t::command_line_interface%get_cla proc~get_cla~2->none~get proc~get_cla~2->proc~parse~2 proc~parse~2->proc~is_required_passed proc~parse~2->proc~parse proc~parse~2->proc~add~2 none~get_varying~2 flap_command_line_interface_t::command_line_interface%get_varying none~get_varying~2->proc~get_cla_list_varying_char~2 none~get_varying~2->proc~get_cla_list_varying_i1p~2 none~get_varying~2->proc~get_cla_list_varying_i2p~2 none~get_varying~2->proc~get_cla_list_varying_i4p~2 none~get_varying~2->proc~get_cla_list_varying_i8p~2 none~get_varying~2->proc~get_cla_list_varying_logical~2 none~get_varying~2->proc~get_cla_list_varying_r4p~2 none~get_varying~2->proc~get_cla_list_varying_r8p~2 none~get~2 flap_command_line_interface_t::command_line_interface%get none~get~2->proc~get_cla_list~2 none~get~2->proc~get_cla~2 proc~fake_call flap_test_group::fake_call proc~fake_call->proc~add~2 proc~fake_call->proc~parse~2 proc~fake_call->none~get~2 program~flap_save_bash_completion flap_save_bash_completion program~flap_save_bash_completion->proc~add~2 program~flap_save_bash_completion->proc~parse~2 program~flap_save_man_page flap_save_man_page program~flap_save_man_page->proc~add~2 program~flap_save_man_page->none~get~2 program~flap_save_usage_to_markdown flap_save_usage_to_markdown program~flap_save_usage_to_markdown->proc~add~2 program~flap_save_usage_to_markdown->none~get~2 program~flap_test_action_store flap_test_action_store program~flap_test_action_store->proc~add~2 program~flap_test_action_store->none~get_varying~2 program~flap_test_action_store->none~get~2 program~flap_test_ansi_color_style flap_test_ansi_color_style program~flap_test_ansi_color_style->proc~add~2 program~flap_test_ansi_color_style->none~get~2 program~flap_test_basic flap_test_basic program~flap_test_basic->proc~add~2 program~flap_test_basic->proc~parse~2 program~flap_test_basic->none~get_varying~2 program~flap_test_basic->none~get~2 program~flap_test_choices_logical flap_test_choices_logical program~flap_test_choices_logical->proc~add~2 program~flap_test_choices_logical->proc~parse~2 program~flap_test_choices_logical->none~get~2 program~flap_test_duplicated_clas flap_test_duplicated_clas program~flap_test_duplicated_clas->proc~add~2 program~flap_test_duplicated_clas->none~get~2 program~flap_test_group_examples flap_test_group_examples program~flap_test_group_examples->proc~add~2 program~flap_test_group_examples->none~get~2 program~flap_test_hidden flap_test_hidden program~flap_test_hidden->proc~add~2 program~flap_test_hidden->none~get~2 program~flap_test_ignore_unknown_clas flap_test_ignore_unknown_clas program~flap_test_ignore_unknown_clas->proc~add~2 program~flap_test_ignore_unknown_clas->none~get~2 program~flap_test_minimal flap_test_minimal program~flap_test_minimal->proc~add~2 program~flap_test_minimal->none~get~2 program~flap_test_nargs_insufficient flap_test_nargs_insufficient program~flap_test_nargs_insufficient->proc~add~2 program~flap_test_nargs_insufficient->none~get~2 program~flap_test_nargs_insufficient~2 flap_test_nargs_insufficient program~flap_test_nargs_insufficient~2->proc~add~2 program~flap_test_nargs_insufficient~2->none~get~2 program~flap_test_nested flap_test_nested program~flap_test_nested->proc~add~2 program~flap_test_nested->proc~parse~2 program~flap_test_nested->none~get~2 program~flap_test_string flap_test_string program~flap_test_string->proc~add~2 program~flap_test_string->proc~parse~2 program~flap_test_string->none~get~2 program~flap_test_group flap_test_group program~flap_test_group->proc~fake_call

Source Code

  subroutine errored(self, error, pref, switch, val_str, log_value)
  !< Trig error occurence and print meaningful message.
  class(command_line_argument), intent(inout) :: self      !< CLA data.
  integer(I4P),                 intent(in)    :: error     !< Error occurred.
  character(*), optional,       intent(in)    :: pref      !< Prefixing string.
  character(*), optional,       intent(in)    :: switch    !< CLA switch name.
  character(*), optional,       intent(in)    :: val_str   !< Value string.
  character(*), optional,       intent(in)    :: log_value !< Logical value to be casted.
  character(len=:), allocatable               :: prefd     !< Prefixing string.

  self%error = error
  if (self%error/=0) then
    prefd = '' ; if (present(pref)) prefd = pref
    prefd = prefd//self%progname//': '//colorize('error', color_fg=self%error_color, style=self%error_style)
    select case(self%error)
    case(ERROR_OPTIONAL_NO_DEF)
      if (self%is_positional) then
        self%error_message = prefd//': "'//trim(str(n=self%position))//'-th" positional option has not a default value!'
      else
        self%error_message = prefd//': named option "'//self%switch//'" has not a default value!'
      endif
    case(ERROR_REQUIRED_M_EXCLUDE)
      self%error_message = prefd//': named option "'//self%switch//'" cannot exclude others'//&
                           ', it being required, only optional ones can!'
    case(ERROR_POSITIONAL_M_EXCLUDE)
      self%error_message = prefd//': "'//trim(str(n=self%position))//&
                           '-th" positional option cannot exclude others, only optional named options can!'
    case(ERROR_NAMED_NO_NAME)
      self%error_message = prefd//': a non positional optiona must have a switch name!'
    case(ERROR_POSITIONAL_NO_POSITION)
      self%error_message = prefd//': a positional option must have a position number different from 0!'
    case(ERROR_POSITIONAL_NO_STORE)
      self%error_message = prefd//': a positional option must have action set to "'//action_store//'"!'
    case(ERROR_M_EXCLUDE)
      self%error_message = prefd//': the options "'//self%switch//'" and "'//self%m_exclude//&
                           '" are mutually exclusive, but both have been passed!'
    case(ERROR_NOT_IN_CHOICES)
      if (self%is_positional) then
        self%error_message = prefd//': value of "'//trim(str(n=self%position))//&
                             '-th" positional option must be chosen in:'
      else
        self%error_message = prefd//': value of named option "'//self%switch//'" must be chosen in: '
      endif
      self%error_message = self%error_message//'('//self%choices//')'
      self%error_message = self%error_message//' but "'//trim(val_str)//'" has been passed!'
    case(ERROR_MISSING_REQUIRED)
      if (.not.self%is_positional) then
        self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//'" is required!'
      else
        self%error_message = prefd//': "'//trim(str(self%position, .true.))//'-th" positional option is required!'
      endif
    case(ERROR_CASTING_LOGICAL)
      self%error_message = prefd//': cannot convert "'//log_value//'" of option "'//self%switch//'" to logical type!'
    case(ERROR_CHOICES_LOGICAL)
      self%error_message = prefd//': cannot use "choices" value check for option "'//self%switch//&
                           '" it being of logical type! The choices are limited to ".true." or ".false." by definition!'
    case(ERROR_NO_LIST)
      if (.not.self%is_positional) then
        self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//&
                             '" has not "nargs" value but an array has been passed to "get" method!'
      else
        self%error_message = prefd//': "'//trim(str(self%position, .true.))//'-th" positional option '//&
                             'has not "nargs" value but an array has been passed to "get" method!'
      endif
    case(ERROR_NARGS_INSUFFICIENT)
      if (.not.self%is_positional) then
        if (self%nargs=='+') then
          self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//&
                               '" requires at least 1 argument but no one remains!'
        else
          self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//'" requires '//&
                               trim(adjustl(self%nargs))//' arguments but no enough ones remain!'
        endif
      else
        if (self%nargs=='+') then
          self%error_message = prefd//': "'//trim(str(self%position, .true.))//&
                               '-th" positional option requires at least 1 argument but no one remains'
        else
          self%error_message = prefd//': "'//trim(str(self%position, .true.))//'-th" positional option requires '//&
                               trim(adjustl(self%nargs))//' arguments but no enough ones remain!'
        endif
      endif
    case(ERROR_VALUE_MISSING)
      self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//'" needs a value that is not passed!'
    case(ERROR_UNKNOWN)
      self%error_message = prefd//': switch "'//trim(adjustl(switch))//'" is unknown!'
    case(ERROR_ENVVAR_POSITIONAL)
      self%error_message = prefd//': "'//trim(str(self%position, .true.))//'-th" positional option '//&
                           'has "envvar" value that is not allowed for positional option!'
    case(ERROR_ENVVAR_NOT_STORE)
      self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//&
                           '" is an envvar with action different from "'//action_store//'" that is not allowed!'
    case(ERROR_ENVVAR_NARGS)
      self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//&
                           '" is an envvar that is not allowed for list valued option!'
    case(ERROR_STORE_STAR_POSITIONAL)
      self%error_message = prefd//': "'//trim(str(self%position, .true.))//'-th" positional option '//&
                           'has "'//action_store_star//'" action that is not allowed for positional option!'
    case(ERROR_STORE_STAR_NARGS)
      self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//&
                           '" has "'//action_store_star//'" action that is not allowed for list valued option!'
    case(ERROR_STORE_STAR_ENVVAR)
      self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//&
                           '" has "'//action_store_star//'" action that is not allowed for environment variable option!'
    case(ERROR_ACTION_UNKNOWN)
      self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//'" has unknown "'//self%act//'" action!'
    case(ERROR_DUPLICATED_CLAS)
      self%error_message = prefd//': switch "'//trim(adjustl(switch))//'" has been passed more than once!'
    case(ERROR_MISSING_REQUIRED_VAL)
      self%error_message = prefd//': named option "'//trim(adjustl(self%switch))//'" requires a value that is not passed!'
    endselect
    call self%print_error_message
  endif
  endsubroutine errored