camerauis/cameraxui/cxengine/inc/cxeexception.h
changeset 46 c826656d6714
parent 42 feebad15db8c
child 52 7e18d488ac5f
equal deleted inserted replaced
42:feebad15db8c 46:c826656d6714
     1 /*
       
     2 * Copyright (c) 2010 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CXEEXCEPTION_H
       
    19 #define CXEEXCEPTION_H
       
    20 
       
    21 #include <exception>
       
    22 
       
    23 /*!
       
    24 * Exception class for engine internal errors.
       
    25 * Contains one integer which can be used to carry error code,
       
    26 * in normal cases which is of type CxeError::Id.
       
    27 */
       
    28 class CxeException : public std::exception
       
    29 {
       
    30 public:
       
    31     /*!
       
    32     * Constructor.
       
    33     */
       
    34     explicit CxeException(int error) : mError(error) {};
       
    35 
       
    36     /*!
       
    37     * Destructor.
       
    38     */
       
    39     virtual ~CxeException() throw() {};
       
    40 
       
    41     /*!
       
    42     * Get the error code causing this exception.
       
    43     * @return The error code.
       
    44     */
       
    45     int error() const { return mError; };
       
    46 
       
    47     /*!
       
    48     * Helper method to throw exception if given status code is an error.
       
    49     * Everything but zero is considered error.
       
    50     * @param status The status code to check.
       
    51     */
       
    52     static void throwIfError(int status) { if (status) { throw new CxeException(status); } }
       
    53 
       
    54 private:
       
    55     //! Error code for this exception.
       
    56     int mError;
       
    57 };
       
    58 
       
    59 #endif // CXEEXCEPTION_H