From 064e1aef596ebd0e780d433d192ae0cc8224e252 Mon Sep 17 00:00:00 2001 From: April Novak Date: Mon, 31 Jul 2017 17:29:35 -0500 Subject: [PATCH] added error and warning code handling in Python API for new codes. Refs #7 --- openmc/capi/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openmc/capi/__init__.py b/openmc/capi/__init__.py index a4f16ab71..fabeac947 100644 --- a/openmc/capi/__init__.py +++ b/openmc/capi/__init__.py @@ -86,6 +86,19 @@ def _error_handler(err, func, args): elif err == _error_code('e_tally_invalid_id'): raise KeyError("No tally exists with ID={}.".format(args[0])) + elif err == _error_code('e_invalid_size'): + raise MemoryError("Array size mismatch with memory allocated.") + + elif err == _error_code('e_cell_no_material'): + raise GeometryError("Operation on cell requires that it be filled" + " with a material.") + + elif err == _error_code('w_below_min_bound'): + warn("Data has not been loaded beyond lower bound of {}.".format(args[0])) + + elif err == _error_code('w_above_max_bound'): + warn("Data has not been loaded beyond upper bound of {}.".format(args[0])) + elif err < 0: raise Exception("Unknown error encountered (code {}).".format(err))