Add pluggable FoX_error_handler hook#4
Merged
jameskermode merged 1 commit intoMay 11, 2026
Conversation
FoX_error_base previously called stop directly, which prevented host programs (notably quippy via libAtoms' system_abort + f90wrap_abort chain) from converting XML parse errors into language-level exceptions. Introduce an optional procedure-pointer hook so a host library can install its own terminator. The historical stop path is preserved as the fallback when no handler is registered. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
m_common_error(FoX_set_error_handler) thatFoX_error_baseconsults before its historicalstop.stoppath is preserved when no handler is registered.Motivation
Needed to fix libAtoms/QUIP#724 — quippy's
Potential(param_filename=...)silently exits the Python interpreter on malformed XML because FoX calls Fortranstopdirectly, bypassing libAtoms'system_abort→f90wrap_abortpath. With this hook, libAtoms registers a handler that routes throughsystem_abort, so Python sees a catchableRuntimeError.Companion QUIP PR will register the handler in
system_initialise.Test plan
tests/test_fox_xml_errors.pyand the existingtest_error_handling_raises_exceptions).stopafter stderr message).🤖 Generated with Claude Code