Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Error Definitions (XML)
  • Error Declarations (IDL)
  • Throwing Exceptions
  • Handling Exceptions

Error Definitions

Error definitions are elements in XML files with the representation for errors and completions. For instance, a simple definition present in the project:

Code Block
languagexml
linenumberstrue
collapsetrue
...
<ErrorCode name="AlreadyInAutomatic" 
           shortDescription="Already in automatic mode" 
           description="Trying to set automatic mode, failed. It has already been set"/>
...

Error Declarations

The errors defined in the XML files need to be declared in the IDLs to be used in component comunications:

Code Block
languagecpp
linenumberstrue
collapsetrue
...
    void setMode(in boolean mode) raises(SYSTEMErr::AlreadyInAutomaticEx);
...

Throwing Exceptions

Throwing exceptions is done in the servant that implements the IDL method that declared the error.

  • Python

    Code Block
    import SYSTEMErrImpl
    ...
        raise SYSTEMErrImpl.AlreadyInAutomaticExImpl().getAlreadyInAutomaticEx()
    ...
  • Java

    Code Block
    import alma.SYSTEMErr.wrappers.AcsJAlreadyInAutomaticEx;
    ...
        throw new AcsJAlreadyInAutomaticEx("Some message...").toAlreadyInAutomaticEx();
    ...
  • C++

    Code Block
    #include <SYSTEMErr.h>
    ...
        throw SYSTEMErr::AlreadyInAutomaticExImpl(__FILE__, __LINE__, "Some message...").getAlreadyInAutomaticEx();
    ...

Handling Exceptions

Handling is done in the component or client that calls a component through its stub.

  • Python

    Code Block
    import SYSTEMErr
    ...
        try:
            ...
        except SYSTEMErr.AlreadyInAutomaticEx as e:
            ...
    ...
  • Java

    Code Block
    import alma.SYSTEMErr.AlreadyInAutomaticEx;
    ...
        try {
            ...
        } catch (AlreadyInAutomaticEx e) {
            ...
        }
    ...
  • C++

    Code Block
    #include <SYSTEMErr.h>
    ...
        try {
            ...
        } catch(SYSTEMErr::AlreadyInAutomaticEx &_ex) {
            ...
        }
    ...