homescreensrv_plat/hs_widget_publisher_api/inc/hsexception.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 08:54:17 +0200
changeset 0 79c6a41cd166
permissions -rw-r--r--
Revision: 200949 Kit: 200951

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Updates applications and icons in Operator Tile.
*
*/


#ifndef __HSEXCEPTION_H__
#define __HSEXCEPTION_H__

#include <exception>

namespace Hs {

/**
 * Class used to encapsulate error information thrown in exceptions by the
 * Homescreen Publishing Api.
 * @code
 * 
 * ObserverClass* dataObserver = new ObserverClass();
 * try 
 * {
 *     HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
 *     if ( hsPublisher )
 *     {
 *         HsWidget& widget =  hsPublisher->createHsWidget( 
 *             "templateName", "widgetName", "uniqueIdentifier" );
 *         //attempt to create the widget again (with the same information) 
 *         //will cause an exception
 *         hsPublisher->createHsWidget( 
 *             "templateName", "widgetName", "uniqueIdentifier" );
 *     }
 * }
 * catch (HsException& exception)
 * {
 *     int errReason = exception.getReason();
 *     //if the exception is thrown, becasue the widget attempted to
 *     //be created already exists the errReason will be KErrAlreadyExists
 * }
 * @endcode
 */
class HsException : public std::exception
    {
public:
	
    /**
     * Constructor of the HsException.
     */
	IMPORT_C HsException( int aLeaveCode );

    /**
     * Destructor of the HsException.
     */
	IMPORT_C virtual ~HsException();
    
    /**
     * Method retrieves the error information contained in the 
     * excpetion object.
     *
     * @code
     * ObserverClass* dataObserver = new ObserverClass();
     * try 
     * {
     *     HsWidgetPublisher* hsPublisher = new HsWidgetPublisher(dataObserver);
     *     hsPublisher->createHsWidget( 
     *         "templateName", "widgetName", "uniqueIdentifier" );
     * }
     * catch (HsException& exception)
     * {
     *      int errReason = exception.getReason();
     * }
     * @endcode
     * @return Error code.
     */
	IMPORT_C int getReason();

private:

	int mLeaveCode;
    
    };
}

#endif /*__HSEXCEPTION_H__*/