Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ArcaneException.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ArcaneException.h (C) 2000-2025 */
9/* */
10/* Exceptions thrown by Arcane. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ARCANEEXCEPTION_H
13#define ARCANE_CORE_ARCANEEXCEPTION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Exception.h"
18#include "arcane/utils/String.h"
19
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
46class ARCANE_CORE_EXPORT BadIDException
47: public Exception
48{
49 public:
50
55 BadIDException(const String& where, const String& invalid_name);
56 ~BadIDException() ARCANE_NOEXCEPT override {}
57
58 public:
59
60 void explain(std::ostream& m) const override;
61
62 private:
63
65};
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
69
77class ARCANE_CORE_EXPORT BadItemIdException
78: public Exception
79{
80 public:
81
88 BadItemIdException(const String& where, Integer bad_id);
89 ~BadItemIdException() ARCANE_NOEXCEPT override {}
90
91 public:
92
93 void explain(std::ostream& m) const override;
94
95 private:
96
98};
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102
107class ARCANE_CORE_EXPORT InternalErrorException
108: public Exception
109{
110 public:
111
112 InternalErrorException(const String& where, const String& why);
113 InternalErrorException(const TraceInfo& where, const String& why);
114 InternalErrorException(const InternalErrorException& ex) ARCANE_NOEXCEPT;
115 ~InternalErrorException() ARCANE_NOEXCEPT override {}
116
117 public:
118
119 void explain(std::ostream& m) const override;
120
121 private:
122
123 String m_why;
124};
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
136class ARCANE_CORE_EXPORT BadVariableKindTypeException
137: public Exception
138{
139 public:
140
141 BadVariableKindTypeException(const TraceInfo& where, IVariable* valid_var,
142 eItemKind kind, eDataType datatype, int dimension);
143 ~BadVariableKindTypeException() ARCANE_NOEXCEPT override {}
144
145 public:
146
147 void explain(std::ostream& m) const override;
148
149 private:
150
151 IVariable* m_valid_var;
152 eItemKind m_item_kind;
153 eDataType m_data_type;
154 int m_dimension;
155};
156
157/*---------------------------------------------------------------------------*/
158/*---------------------------------------------------------------------------*/
159
167class ARCANE_CORE_EXPORT BadPartialVariableItemGroupNameException
168: public Exception
169{
170 public:
171
172 BadPartialVariableItemGroupNameException(const TraceInfo& where, IVariable* valid_var,
173 const String& item_group_name);
174 ~BadPartialVariableItemGroupNameException() ARCANE_NOEXCEPT override {}
175
176 public:
177
178 void explain(std::ostream& m) const override;
179
180 private:
181
182 IVariable* m_valid_var;
183 String m_item_group_name;
184};
185
186/*---------------------------------------------------------------------------*/
187/*---------------------------------------------------------------------------*/
188
193class ARCANE_CORE_EXPORT UnknownItemTypeException
194: public Exception
195{
196 public:
197
198 UnknownItemTypeException(const String& where, Integer nb_node, Integer item_id);
199 UnknownItemTypeException(const UnknownItemTypeException& ex) ARCANE_NOEXCEPT;
200 ~UnknownItemTypeException() ARCANE_NOEXCEPT override {}
201
202 public:
203
204 void explain(std::ostream& m) const override;
205
206 private:
207
208 Integer m_nb_node;
209 Integer m_item_id;
210};
211
212/*---------------------------------------------------------------------------*/
213/*---------------------------------------------------------------------------*/
214
219class ARCANE_CORE_EXPORT BadReferenceException
220: public Exception
221{
222 public:
223
224 explicit BadReferenceException(const String& where);
225 ~BadReferenceException() ARCANE_NOEXCEPT override {}
226
227 public:
228
229 void explain(std::ostream& m) const override;
230
231 private:
232};
233
234/*---------------------------------------------------------------------------*/
235/*---------------------------------------------------------------------------*/
236
241class ARCANE_CORE_EXPORT ReaderWriterException
242: public Exception
243{
244 public:
245
246 ReaderWriterException(const String& where, const String& message);
247 ReaderWriterException(const TraceInfo& where, const String& message);
248 ReaderWriterException(const ReaderWriterException& ex) ARCANE_NOEXCEPT;
249 ~ReaderWriterException() ARCANE_NOEXCEPT override {}
250
251 public:
252
253 void explain(std::ostream& m) const override;
254};
255
256/*---------------------------------------------------------------------------*/
257/*---------------------------------------------------------------------------*/
258
263class ARCANE_CORE_EXPORT AssertionException
264: public Exception
265{
266 public:
267
271 explicit AssertionException(const TraceInfo& where);
272
277 AssertionException(const TraceInfo& where, const String& expected, const String& actual);
278
279 public:
280
281 void explain(std::ostream& m) const override;
282
284 const char* file() const { return m_file; }
285
287 int line() const { return m_line; }
288
289 public:
290
291 using Exception::message;
292 using Exception::where;
293
294 private:
295
296 const char* m_file;
297 int m_line;
298};
299
300/*---------------------------------------------------------------------------*/
301/*---------------------------------------------------------------------------*/
302
303} // End namespace Arcane
304
305/*---------------------------------------------------------------------------*/
306/*---------------------------------------------------------------------------*/
307
308#endif
Declarations of Arcane's general types.
const String & where() const
Location of the exception.
const char * file() const
File of the exception.
int line() const
Line of the exception.
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
AssertionException(const TraceInfo &where)
BadIDException(const String &where, const String &invalid_name)
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
String m_invalid_name
Invalid identifier.
BadItemIdException(const String &where, Integer bad_id)
Constructs an exception.
Integer m_bad_id
Invalid ID.
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
const String & where() const
Location of the exception.
const String & message() const
Exception message.
Exception(const String &name, const String &where)
Interface of a variable.
Definition IVariable.h:40
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
void explain(std::ostream &m) const override
Explains the cause of the exception in the stream o.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
eItemKind
Mesh entity type.
eDataType
Data type.
Definition DataTypes.h:41