Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: e32cmn.h

TRAPD

TRAPD (_r, _s) TInt _r;                                             \
    {                                                       \
    _r = 0;                                                 \
    { TRAP_INSTRUMENTATION_START; }                         \
    try {                                                  \
        __WIN32SEHTRAP                                      \
        TTrapHandler* ____t = User::MarkCleanupStack();     \
        _s;                                                 \
        User::UnMarkCleanupStack(____t);                    \
        { TRAP_INSTRUMENTATION_NOLEAVE; }                   \
        __WIN32SEHUNTRAP                                    \
        }                                                   \
    catch (XLeaveException& l)                              \
        {                                                   \
        _r = l.GetReason();                                 \
        { TRAP_INSTRUMENTATION_LEAVE(_r); }                 \
        }                                                   \
    catch (...)                                             \
        {                                                   \
        User::Invariant();                                  \
        }                                                   \
    { TRAP_INSTRUMENTATION_END; }                           \
    }

Description

Executes the set of C++ statements _s under a trap harness.

Use this macro in the same way as you would TRAP, except that the variable _r is defined as part of the macro (and is therefore valid for the rest of the block in which the macro occurs). Often, this saves a line of code.

Parameters

_r

A name, which will be declared as a TInt, and will receive the result of any User::Leave() executed within _s or, if no leave occurred, it will be set to KErrNone. After the macro, _r remains in scope until the end of its enclosing block.

_s

C++ statements which will be executed under a trap harness.