apoCHARMM 1.0.0
High-performance molecular dynamics simulations on GPUs
 
Loading...
Searching...
No Matches
apocharmm.error.ApoCharmmError Class Reference

Represents one failed apoCHARMM native operation in Python. More...

Inherits RuntimeError.

Public Member Functions

None __init__ (self, int status, str context, str native_diagnostic)
 Constructs a Python exception from status and diagnostic fields.
 
int status (self)
 Returns the exact numeric C ABI status.
 
str status_name (self)
 Returns the symbolic name associated with the numeric status.
 
str context (self)
 Returns the Python-facing operation context.
 
str native_diagnostic (self)
 Returns the copied and decoded native diagnostic.
 
str message (self)
 Returns the complete rendered Python exception message.
 

Detailed Description

Represents one failed apoCHARMM native operation in Python.

The exception retains the exact numeric C ABI status, a known exported status name or APO_STATUS_UNKNOWN, the Python operation context, the decoded native diagnostic, and the final rendered message. It is also a RuntimeError, so callers may catch either class.

check_status() copies and decodes the native thread-local C string before constructing this object. The exception therefore owns Python references that remain valid after later native calls. The rendered message normalizes CRLF and lone carriage returns to line feeds, while native_diagnostic retains the original decoded text.

Constructor & Destructor Documentation

◆ __init__()

None apocharmm.error.ApoCharmmError.__init__ (   self,
int  status,
str  context,
str  native_diagnostic 
)

Constructs a Python exception from status and diagnostic fields.

status is converted with int(). Unknown integer values are retained and use APO_STATUS_UNKNOWN. A single-line diagnostic is separated from the context header by ": ". A multiline diagnostic begins on the next line unless it already starts with a newline, which preserves the native apoCHARMM banner layout.

Parameters
[in]statusC ABI status or another object accepted by int().
[in]contextPython-facing operation description retained in the rendered header.
[in]native_diagnosticDecoded native diagnostic retained without newline normalization.
Exceptions
TypeErrorIf status cannot be converted with int().
ValueErrorIf int() rejects the supplied status value.
OverflowErrorIf int() reports an overflow while converting status.

Member Function Documentation

◆ context()

str apocharmm.error.ApoCharmmError.context (   self)

Returns the Python-facing operation context.

Returns
The context supplied at construction.

◆ message()

str apocharmm.error.ApoCharmmError.message (   self)

Returns the complete rendered Python exception message.

Returns
The context, status name, numeric status, and newline-normalized native diagnostic in the same text returned by str(error).

◆ native_diagnostic()

str apocharmm.error.ApoCharmmError.native_diagnostic (   self)

Returns the copied and decoded native diagnostic.

Returns
The diagnostic supplied at construction, before rendered-message newline normalization.

◆ status()

int apocharmm.error.ApoCharmmError.status (   self)

Returns the exact numeric C ABI status.

Returns
The integer supplied at construction, including an unknown nonzero value.

◆ status_name()

str apocharmm.error.ApoCharmmError.status_name (   self)

Returns the symbolic name associated with the numeric status.

Returns
The matching exported APO_STATUS_* name, or "APO_STATUS_UNKNOWN" when the numeric value is not recognized.