camerauis/cameraxui/cxengine/inc/api/cxeexception.h
author hgs
Wed, 18 Aug 2010 14:02:45 +0300
changeset 51 ccc0e7e3344f
parent 45 24fd82631616
permissions -rw-r--r--
201031_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     1
/*
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     3
* All rights reserved.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     8
*
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
     9
* Initial Contributors:
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    11
*
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    12
* Contributors:
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    13
*
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    14
* Description:
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    15
*
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    16
*/
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    17
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    18
#ifndef CXEEXCEPTION_H
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    19
#define CXEEXCEPTION_H
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    20
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    21
#include <exception>
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    22
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    23
/*!
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    24
* Exception class for engine internal errors.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    25
* Contains one integer which can be used to carry error code,
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    26
* in normal cases which is of type CxeError::Id.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    27
*/
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    28
class CxeException : public std::exception
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    29
{
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    30
public:
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    31
    /*!
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    32
    * Constructor.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    33
    */
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    34
    explicit CxeException(int error) : mError(error) {};
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    35
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    36
    /*!
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    37
    * Destructor.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    38
    */
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    39
    virtual ~CxeException() throw() {};
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    40
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    41
    /*!
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    42
    * Get the error code causing this exception.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    43
    * @return The error code.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    44
    */
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    45
    int error() const { return mError; };
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    46
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    47
    /*!
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    48
    * Helper method to throw exception if given status code is an error.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    49
    * Everything but zero is considered error.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    50
    * @param status The status code to check.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    51
    */
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    52
    static void throwIfError(int status) { if (status) { throw new CxeException(status); } }
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    53
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    54
private:
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    55
    //! Error code for this exception.
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    56
    int mError;
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    57
};
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    58
0e652f8f1fbd 201027_1
hgs
parents:
diff changeset
    59
#endif // CXEEXCEPTION_H