Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArcaneException.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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.cc (C) 2000-2024 */
9/* */
10/* Exceptions lancées par l'architecture. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/ArcaneException.h"
15
16#include "arcane/utils/Iostream.h"
17
18#include "arcane/IVariable.h"
19#include "arcane/IModule.h"
20#include "arcane/IBase.h"
21#include "arcane/utils/TraceInfo.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26ARCANE_BEGIN_NAMESPACE
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31BadIDException::
32BadIDException(const String& where,const String& invalid_name)
33: Exception("BadID",where)
34, m_invalid_name(invalid_name)
35{
36}
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
40
42explain(std::ostream& m) const
43{
44 m << "Name '" << m_invalid_name << "' is not a valid identifier.\n";
45 m << "Identifiers must start with an alphabetical character (a-zA-Z)\n";
46 m << "followed by alphabetical characters, figures,\n";
47 m << "underscores '_' or dots '.'\n";
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
57BadItemIdException(const String& where,Integer bad_id)
58: Exception("BadItemId",where)
59, m_bad_id(bad_id)
60{
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
67explain(std::ostream& m) const
68{
69 m << "Trying to use invalid item identifier: " << m_bad_id;
70}
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78InternalErrorException::
79InternalErrorException(const String& where,const String& why)
80: Exception("InternalError",where)
81, m_why(why)
82{
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88InternalErrorException::
89InternalErrorException(const TraceInfo& where,const String& why)
90: Exception("InternalError",where)
91, m_why(why)
92{
93}
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98InternalErrorException::
99InternalErrorException(const InternalErrorException& ex) ARCANE_NOEXCEPT
100: Exception(ex)
101, m_why(ex.m_why)
102{
103}
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
109explain(std::ostream& m) const
110{
111 m << "Internal error ocurred:\n";
112 m << "'" << m_why << "'\n";
113}
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121BadVariableKindTypeException::
122BadVariableKindTypeException(const TraceInfo& where,IVariable* prv,
123 eItemKind kind,eDataType data_type,int dimension)
124: Exception("BadVariableKindType",where)
125, m_valid_var(prv)
126, m_item_kind(kind)
127, m_data_type(data_type)
128, m_dimension(dimension)
129{
130}
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134
136explain(std::ostream& m) const
137{
138 m << "Wrong variable type:\n"
139 << "Variable '" << m_valid_var->name() << "'\n";
140 m << "declared as '" << m_item_kind << '.' << m_data_type << "." << m_dimension
141 << "' has already been declared\n"
142 << "as '" << m_valid_var->itemKind() << '.' << m_valid_var->dataType()
143 << "." << m_valid_var->dimension()
144 << "'";
145}
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150BadPartialVariableItemGroupNameException::
151BadPartialVariableItemGroupNameException(const TraceInfo& where,IVariable* prv,
152 const String& item_group_name)
153: Exception("BadVariableKindType",where)
154, m_valid_var(prv)
155, m_item_group_name(item_group_name)
156{
157}
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
163explain(std::ostream& m) const
164{
165 m << "Wrong partial variable type:\n"
166 << "Partial Variable '" << m_valid_var->name() << "'\n";
167 m << "declared on item group '" << m_item_group_name
168 << "' has already been declared\n"
169 << "on item group '" << m_valid_var->itemGroupName()
170 << "'";
171}
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
175
176UnknownItemTypeException::
177UnknownItemTypeException(const String& where,Integer nb_node,Integer item_id)
178: Exception("UnknownItemType",where)
179, m_nb_node(nb_node)
180, m_item_id(item_id)
181{
182}
183
184/*---------------------------------------------------------------------------*/
185/*---------------------------------------------------------------------------*/
186
187UnknownItemTypeException::
188UnknownItemTypeException(const UnknownItemTypeException& ex) ARCANE_NOEXCEPT
189: Exception(ex)
190, m_nb_node(ex.m_nb_node)
191, m_item_id(ex.m_item_id)
192{
193}
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
197
199explain(std::ostream& m) const
200{
201 m << "Item number <" << m_item_id << "> with " << m_nb_node << " nodes\n"
202 << "is not a known type.\n";
203}
204
205/*---------------------------------------------------------------------------*/
206/*---------------------------------------------------------------------------*/
207
208/*---------------------------------------------------------------------------*/
209/*---------------------------------------------------------------------------*/
210
211BadReferenceException::
212BadReferenceException(const String& where)
213: Exception("BadReference",where)
214{
215}
216
217/*---------------------------------------------------------------------------*/
218/*---------------------------------------------------------------------------*/
219
221explain(std::ostream& m) const
222{
223 m << "Trying to dereference a null pointer.\n";
224}
225
226/*---------------------------------------------------------------------------*/
227/*---------------------------------------------------------------------------*/
228
229/*---------------------------------------------------------------------------*/
230/*---------------------------------------------------------------------------*/
231
232ReaderWriterException::
233ReaderWriterException(const String& where,const String& message)
234: Exception("ReaderWriterException",where, message)
235{
236}
237
238/*---------------------------------------------------------------------------*/
239/*---------------------------------------------------------------------------*/
240
241ReaderWriterException::
242ReaderWriterException(const TraceInfo& where,const String& message)
243: Exception("ReaderWriterException",where, message)
244{
245}
246
247/*---------------------------------------------------------------------------*/
248/*---------------------------------------------------------------------------*/
249
250ReaderWriterException::
251ReaderWriterException(const ReaderWriterException& ex) ARCANE_NOEXCEPT
252: Exception(ex)
253{
254}
255
256/*---------------------------------------------------------------------------*/
257/*---------------------------------------------------------------------------*/
258
260explain(std::ostream& m) const
261{
262 m << "Exception reading/writing.\n";
263}
264
265/*---------------------------------------------------------------------------*/
266/*---------------------------------------------------------------------------*/
267
268/*---------------------------------------------------------------------------*/
269/*---------------------------------------------------------------------------*/
270
272AssertionException(const TraceInfo& where)
273: Exception("AssertionException", where)
274, m_file(where.file())
275, m_line(where.line())
276{
277}
278
279/*---------------------------------------------------------------------------*/
280/*---------------------------------------------------------------------------*/
281
283AssertionException(const TraceInfo& where, const String& expected, const String& actual)
284: Exception("ReaderWriterException", where, "Actual : " + actual + ". Expected : " + expected + ".")
285, m_file(where.file())
286, m_line(where.line())
287{
288}
289
290/*---------------------------------------------------------------------------*/
291/*---------------------------------------------------------------------------*/
292
294explain(std::ostream& m) const
295{
296 m << "Assertion failed.\n";
297}
298
299/*---------------------------------------------------------------------------*/
300/*---------------------------------------------------------------------------*/
301
302ARCANE_END_NAMESPACE
303
304/*---------------------------------------------------------------------------*/
305/*---------------------------------------------------------------------------*/
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
AssertionException(const TraceInfo &where)
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
String m_invalid_name
Identifiant invalide.
BadItemIdException(const String &where, Integer bad_id)
Construit une exception.
Integer m_bad_id
Numéro invalide.
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
Interface d'une variable.
Definition IVariable.h:54
virtual eDataType dataType() const =0
Type de la donnée gérée par la variable (Real, Integer, ...)
virtual eItemKind itemKind() const =0
Type des entités du maillage sur lequel repose la variable.
virtual Integer dimension() const =0
Dimension de la variable.
virtual String itemGroupName() const =0
Nom du groupe d'entité associée.
virtual String name() const =0
Nom de la variable.
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
void explain(std::ostream &m) const override
Explique la cause de l'exception dans le flot o.
Classe de base d'une exception.
Chaîne de caractères unicode.
eItemKind
Genre d'entité de maillage.
eDataType
Type d'une donnée.
Definition DataTypes.h:39