Add a call location to the stack trace Typically called when propagating errors upward
Example: call some_routine(…, error) if (error%has_error()) then call error%add_context(“mqc_mbe:compute_energy”) return end if
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(inout) | :: | this | |||
| character(len=*), | intent(in) | :: | location |
pure subroutine error_add_context(this, location) !! Add a call location to the stack trace !! Typically called when propagating errors upward !! !! Example: !! call some_routine(..., error) !! if (error%has_error()) then !! call error%add_context("mqc_mbe:compute_energy") !! return !! end if class(error_t), intent(inout) :: this character(len=*), intent(in) :: location if (this%stack_depth < MAX_STACK_DEPTH) then this%stack_depth = this%stack_depth + 1 this%call_stack(this%stack_depth) = location end if ! If stack is full, silently ignore (could print warning in non-pure version) end subroutine error_add_context