|
1 /* |
|
2 * Copyright (c) 2009 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: Mifconv exception class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MIFCONVEXCEPTION_H__ |
|
20 #define __MIFCONVEXCEPTION_H__ |
|
21 |
|
22 #include "mifconv.h" |
|
23 |
|
24 /** |
|
25 * MifConvException class |
|
26 */ |
|
27 class MifConvException |
|
28 { |
|
29 public: |
|
30 |
|
31 /** |
|
32 * Default constructor |
|
33 */ |
|
34 MifConvException(); |
|
35 |
|
36 /** |
|
37 * Constructor |
|
38 */ |
|
39 MifConvException(const MifConvString& str, const MifConvString& file = MifConvString(), int line = 0); |
|
40 |
|
41 /** |
|
42 * Copy constructor |
|
43 */ |
|
44 MifConvException(const MifConvException& rhs); |
|
45 |
|
46 /** |
|
47 * Destructor |
|
48 */ |
|
49 virtual ~MifConvException(); |
|
50 |
|
51 /** |
|
52 * Sets the error string to be shown to user. |
|
53 * @param str Error string |
|
54 */ |
|
55 void SetString(const MifConvString& str); |
|
56 |
|
57 /** |
|
58 * Returns the error string |
|
59 * @return Error string |
|
60 */ |
|
61 const MifConvString& String() const; |
|
62 |
|
63 /** |
|
64 * Returns the error string |
|
65 * @return Error string |
|
66 */ |
|
67 MifConvString& String(); |
|
68 |
|
69 /** |
|
70 * Sets the file name |
|
71 * @param filename Source code file name |
|
72 */ |
|
73 void SetFile(const MifConvString& filename); |
|
74 |
|
75 /** |
|
76 * Sets the line in the file |
|
77 * @param line Line number in the source code file |
|
78 */ |
|
79 void SetLine(int line); |
|
80 |
|
81 /** |
|
82 * Returns the filename |
|
83 * @return Source code filename |
|
84 */ |
|
85 const MifConvString& File() const; |
|
86 |
|
87 /** |
|
88 * Returns the line number |
|
89 * @return Line number in the source code file |
|
90 */ |
|
91 int Line() const; |
|
92 |
|
93 protected: |
|
94 |
|
95 MifConvString iString; |
|
96 MifConvString iFile; |
|
97 int iLine; |
|
98 }; |
|
99 |
|
100 inline void THROW_ERROR_COMMON(const MifConvString& errorMsg, const MifConvString file = MifConvString(), int line = 0 ) |
|
101 { |
|
102 throw MifConvException( MifConvString("ERROR: " + errorMsg + "\n"), file, line ); |
|
103 } |
|
104 |
|
105 #endif |