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