epoc32/include/hsexception.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  Updates applications and icons in Operator Tile.
    15 *
    16 */
    17 
    18 
    19 #ifndef __HSEXCEPTION_H__
    20 #define __HSEXCEPTION_H__
    21 
    22 #include <exception>
    23 
    24 namespace Hs {
    25 
    26 /**
    27  * Class used to encapsulate error information thrown in exceptions by the
    28  * Homescreen Publishing Api.
    29  * @code
    30  * 
    31  * ObserverClass* dataObserver = new ObserverClass();
    32  * try 
    33  * {
    34  *     HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
    35  *     if ( hsPublisher )
    36  *     {
    37  *         HsWidget& widget =  hsPublisher->createHsWidget( 
    38  *             "templateName", "widgetName", "uniqueIdentifier" );
    39  *         //attempt to create the widget again (with the same information) 
    40  *         //will cause an exception
    41  *         hsPublisher->createHsWidget( 
    42  *             "templateName", "widgetName", "uniqueIdentifier" );
    43  *     }
    44  * }
    45  * catch (HsException& exception)
    46  * {
    47  *     int errReason = exception.getReason();
    48  *     //if the exception is thrown, becasue the widget attempted to
    49  *     //be created already exists the errReason will be KErrAlreadyExists
    50  * }
    51  * @endcode
    52  */
    53 class HsException : public std::exception
    54     {
    55 public:
    56 	
    57     /**
    58      * Constructor of the HsException.
    59      */
    60 	IMPORT_C HsException( int aLeaveCode );
    61 
    62     /**
    63      * Destructor of the HsException.
    64      */
    65 	IMPORT_C virtual ~HsException();
    66     
    67     /**
    68      * Method retrieves the error information contained in the 
    69      * excpetion object.
    70      *
    71      * @code
    72      * ObserverClass* dataObserver = new ObserverClass();
    73      * try 
    74      * {
    75      *     HsWidgetPublisher* hsPublisher = new HsWidgetPublisher(dataObserver);
    76      *     hsPublisher->createHsWidget( 
    77      *         "templateName", "widgetName", "uniqueIdentifier" );
    78      * }
    79      * catch (HsException& exception)
    80      * {
    81      *      int errReason = exception.getReason();
    82      * }
    83      * @endcode
    84      * @return Error code.
    85      */
    86 	IMPORT_C int getReason();
    87 
    88 private:
    89 
    90 	int mLeaveCode;
    91     
    92     };
    93 }
    94 
    95 #endif /*__HSEXCEPTION_H__*/