PrevNextUpHome SophiaFramework UNIVERSE 5.3
static_exception
Template class which implements the pseudo-exception handling.
#include <SFCType.h.hpp>
class static_exception;

Description

The exception of C++ programming language is not available in the ARM compiler.

The static_exception class provides the exception handling mechanism similar to C++ programming language.

When using the static_exception class, it is necessary to create a class derived from the static_exception class.

"T" in the template argument of static_exception must be the class where the SFCError type is available.

Reference

The error processing of SophiaFramework

Member

Constructor/Destructor
static_exception( Void )
Constructor of static_exception class.
~static_exception( Void )
Destructor of the static_exception class.
Public Functions
T const & static_catch( Void )
Get the current exception.
Protected Functions
Void static_throw( static_exception< T > const & param )
Set an exception.
Void static_throw( T const & param )
Set an exception.
Bool static_try( Void )
Confirm whether or not the exception is retained.

static_exception::static_exception
Constructor of static_exception class.
[ public, explicit ]
static_exception(Void);

Description

The value of exception is initialized with SFERR_NO_ERROR.


static_exception::~static_exception
Destructor of the static_exception class.
[ protected ]
~static_exception(
    Void    
);

static_exception::static_catch
Get the current exception.
[ public, const ]
T const & static_catch(
    Void    
);

Example

switch (static_catch()) {
  // processing according to the error
  ...
}

static_exception::static_throw
Set an exception.
[ protected ]
Void static_throw(
    static_exception< T > const & param   // the source static_exception object
);
[ protected ]
Void static_throw(
    T const & param   // the exception to specify
);

Description

The "static_throw" statement has a little different semantics from that of the "throw" in the C++ programming language. The next statement after the "static_throw" statement is always executed.

To exit the function, write the "return" statement explicitly after the "static_throw" statement.

The function including the "static_throw" statements can be marked with the "static_throws" macro.

Example

Void func(Void) static_throws
{
  // check the current exception
  if (!static_try()) { 
    // when error occurs:
    static_throw(SFERR_FAILED);
    return;
  }
  ...
}

static_exception::static_try
Confirm whether or not the exception is retained.
[ protected, const ]
Bool static_try(
    Void    
);

Return value

  • If Not retained: true
  • If retained: false

Example


// check whether error occurs
if (static_try()) { 
  // when no exception occurs:
  ...
} else {
  // when an exception occurs:
  ...
}