error_add_context Subroutine

private pure subroutine error_add_context(self, location)

Add a call location to the stack trace Typically called when propagating errors upward

Example: call some_routine(…, err) if (err%has_error()) then call err%add_context(“pic_module:my_subroutine”) return end if

Type Bound

error_t

Arguments

Type IntentOptional Attributes Name
class(error_t), intent(inout) :: self
character(len=*), intent(in) :: location

Source Code

   pure subroutine error_add_context(self, location)
      !! Add a call location to the stack trace
      !! Typically called when propagating errors upward
      !!
      !! Example:
      !!   call some_routine(..., err)
      !!   if (err%has_error()) then
      !!      call err%add_context("pic_module:my_subroutine")
      !!      return
      !!   end if
      class(error_t), intent(inout) :: self
      character(len=*), intent(in) :: location

      if (self%stack_depth < MAX_STACK_DEPTH) then
         self%stack_depth = self%stack_depth + 1
         self%call_stack(self%stack_depth) = location
      end if
   end subroutine error_add_context