First public contribution.
1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\us_trp.cpp
24 EXPORT_C TTrapHandler::TTrapHandler()
31 #ifndef __LEAVE_EQUALS_THROW__
33 EXPORT_C void TTrap::UnTrap()
35 // Pop the current trap frame
39 TTrapHandler *pH=Exec::PopTrapFrame()->iHandler;
45 #else //__LEAVE_EQUALS_THROW__
47 EXPORT_C void User::Leave(TInt aReason)
49 Leaves the currently executing function, unwinds the call stack, and returns
50 from the most recently entered trap harness.
52 @param aReason The value returned from the most recent call to TRAP or TRAPD.
53 This is known as the reason code and, typically, it gives the
54 reason for the environment or user error causing this leave
61 #ifdef __USERSIDE_THREAD_DATA__
63 TTrapHandler* pH = GetTrapHandler();
65 TTrapHandler* pH = Exec::LeaveStart();
68 pH->Leave(aReason); // causes things on the cleanup stack to be cleaned up
69 throw XLeaveException(aReason);
72 #endif // !__LEAVE_EQUALS_THROW__
75 // Private declaration to prevent def file branching
76 #ifndef __SUPPORT_CPP_EXCEPTIONS__
80 IMPORT_C TInt GetReason() const;
82 #endif //__SUPPORT_CPP_EXCEPTIONS__
84 #if !defined(__LEAVE_EQUALS_THROW__) || !defined(__WINS__)
85 EXPORT_C TInt XLeaveException::GetReason() const
87 #ifdef __SUPPORT_CPP_EXCEPTIONS__
90 #else // !__SUPPORT_CPP_EXCEPTIONS__
92 #endif //__SUPPORT_CPP_EXCEPTIONS__
94 #elif defined(__LEAVE_EQUALS_THROW__) && defined(__SYMC__)
95 EXPORT_C TInt XLeaveException::GetReason() const
97 #ifdef __SUPPORT_CPP_EXCEPTIONS__
100 #else // !__SUPPORT_CPP_EXCEPTIONS__
102 #endif //__SUPPORT_CPP_EXCEPTIONS__
104 #endif // !defined(__LEAVE_EQUALS_THROW__) || !defined(__WINS__)
106 EXPORT_C void User::LeaveNoMemory()
108 Leaves with the specific reason code KErrNoMemory.
114 User::Leave(KErrNoMemory);
120 EXPORT_C TInt User::LeaveIfError(TInt aReason)
122 Leaves or returns with a specified reason code.
124 If the reason code is negative the function leaves, and the reason code is
125 returned through the trap harness.
127 If the reason code is zero or positive, the function simply returns with the
130 @param aReason The reason code.
132 @return If the function returns, the reason code which is either zero or positive.
137 User::Leave(aReason);
144 EXPORT_C TAny * User::LeaveIfNull(TAny *aPtr)
146 Leaves with the reason code KErrNoMemory, if the specified pointer is NULL.
148 If the pointer is not NULL, the function simply returns with the value of
151 @param aPtr The pointer to be tested.
153 @return If the function returns, the value of aPtr.
158 User::LeaveNoMemory();