homescreensrv_plat/hs_widget_publisher_api/inc/hsexception.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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 "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.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__*/