From 105cee4ef8ac07cc4674a8330d1fa2f842fc8779 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 10 Mar 2026 22:43:31 -0700 Subject: [PATCH] Throw Exceptions in Asserts Fix #1348: Set AMReX `system::throw_exception` so that in interactive usage we can potentially catch an exception and handle it, instead of terminating the process (Python interpreter). --- src/initialization/InitParser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/initialization/InitParser.cpp b/src/initialization/InitParser.cpp index 8d4b0feab..56966d411 100644 --- a/src/initialization/InitParser.cpp +++ b/src/initialization/InitParser.cpp @@ -18,6 +18,11 @@ namespace impactx::initialization { amrex::ParmParse pp_amrex("amrex"); + // throw exceptions in asserts, to enable optional error handling, especially in Python + // https://amrex-codes.github.io/amrex/docs_html/RuntimeParameters.html#amrex.throw_exception + bool throw_exception = true; // AMReX' default: false + pp_amrex.queryAdd("throw_exception", throw_exception); + // https://amrex-codes.github.io/amrex/docs_html/GPU.html#inputs-parameters bool abort_on_out_of_gpu_memory = true; // AMReX' default: false pp_amrex.queryAdd("abort_on_out_of_gpu_memory", abort_on_out_of_gpu_memory);