apoCHARMM 1.0.0
High-performance molecular dynamics simulations on GPUs
 
Loading...
Searching...
No Matches
ApoCharmmError.h File Reference

Declares categorized native errors and source-capturing error macros. More...

Classes

class  ApoCharmmError
 Represents a categorized native error with source metadata. More...
 

Macros

#define APOCHARMM_THROW(errorCode, message)    throw ::ApoCharmmError((errorCode), (message), __FILE__, __func__, __LINE__)
 Throws a categorized apoCHARMM error at the current source location.
 
#define APOCHARMM_REQUIRE(condition, errorCode, message)
 Throws a categorized apoCHARMM error unless a condition is true.
 

Enumerations

enum class  ApoCharmmErrorCode {
  InvalidArgument , Runtime , Cuda , NotInitialized ,
  NotImplemented
}
 Identifies the category of an apoCHARMM native failure. More...
 

Functions

std::string_view GetApoCharmmErrorCodeName (const ApoCharmmErrorCode code) noexcept
 Returns the diagnostic name of an apoCHARMM error category.
 

Detailed Description

Declares categorized native errors and source-capturing error macros.

Macro Definition Documentation

◆ APOCHARMM_REQUIRE

#define APOCHARMM_REQUIRE (   condition,
  errorCode,
  message 
)
Value:
do { \
if (!(condition)) { \
APOCHARMM_THROW((errorCode), (message)); \
} \
} while (false)

Throws a categorized apoCHARMM error unless a condition is true.

The macro evaluates condition exactly once. It evaluates errorCode and message only when the condition is false, then delegates source capture and construction to APOCHARMM_THROW.

Parameters
[in]conditionExpression whose contextual Boolean value must be true.
[in]errorCodeExpression yielding the retained ApoCharmmErrorCode when condition is false.
[in]messageExpression convertible to std::string_view; evaluated and copied only when condition is false.
Exceptions
ApoCharmmErrorIf condition is false and construction succeeds.
std::bad_allocIf failure-path storage cannot be allocated.
std::length_errorIf the failure diagnostic exceeds a string limit.
Precondition
The macro is expanded in function scope so __func__ is available.
Postcondition
If condition is true, execution continues and neither errorCode nor message is evaluated.
Warning
Do not use this macro from a noexcept cleanup path or destructor.

◆ APOCHARMM_THROW

#define APOCHARMM_THROW (   errorCode,
  message 
)     throw ::ApoCharmmError((errorCode), (message), __FILE__, __func__, __LINE__)

Throws a categorized apoCHARMM error at the current source location.

The macro evaluates each argument exactly once and captures __FILE__, __func__, and __LINE__ from the expansion site.

Parameters
[in]errorCodeExpression yielding the retained ApoCharmmErrorCode.
[in]messageExpression convertible to std::string_view; its text is copied by the exception constructor.
Exceptions
ApoCharmmErrorAlways when exception construction succeeds.
std::bad_allocIf exception storage cannot be allocated.
std::length_errorIf the diagnostic exceeds a string limit.
Precondition
The macro is expanded in function scope so __func__ is available.
Warning
Do not use this macro from a noexcept cleanup path or destructor.

Enumeration Type Documentation

◆ ApoCharmmErrorCode

enum class ApoCharmmErrorCode
strong

Identifies the category of an apoCHARMM native failure.

The category is stored independently from the human-readable diagnostic. C ABI boundaries map each declared value to the corresponding apo_status value without relying on this enum's underlying integer representation.

Enumerator
InvalidArgument 

Indicates that the caller supplied an invalid argument.

Runtime 

Indicates a runtime failure without a more specific category.

Cuda 

Indicates that a CUDA operation failed.

NotInitialized 

Indicates that an operation requires state that is not initialized.

NotImplemented 

Indicates that a recognized operation is not implemented.

Function Documentation

◆ GetApoCharmmErrorCodeName()

std::string_view GetApoCharmmErrorCodeName ( const ApoCharmmErrorCode  code)
noexcept

Returns the diagnostic name of an apoCHARMM error category.

Parameters
[in]codeCategory to name.
Returns
A borrowed view of program-lifetime static storage. Declared categories return their exact enumerator names; any other value returns "Unknown".