Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
CaseOptionException.cc
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/* CaseOptionException.cc (C) 2000-2018 */
9/* */
10/* Exception related to the dataset. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/Iostream.h"
17#include "arcane/utils/StringBuilder.h"
18
19#include "arcane/core/CaseOptionException.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
31CaseOptionException(const String& where, const String& node_name,
32 const XmlNode& parent)
33: Exception("CaseOptionException", where)
34, m_node_name(node_name)
35, m_parent(parent)
36{
38 sb = "Configuration item:\n\n"
39 " <" +
40 m_parent.xpathFullName() + String("/") + m_node_name;
41 sb += ">\n\n"
42 "can not be found.\n\n"
43 "Make sure the configuration file is valid and up to date "
44 "with the code.\n";
45 m_message = sb.toString();
46 setCollective(true);
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
53CaseOptionException(const String& where, const String& node_name,
54 const XmlNode& parent, const String& value,
55 const String& type)
56: Exception("CaseOptionException", where)
57, m_node_name(node_name)
58, m_parent(parent)
59, m_value(value)
60, m_type(type)
61{
63 sb = "Configuration item:\n"
64 "<" +
65 m_parent.xpathFullName() + String("/") + m_node_name;
66 sb += "> is not valid.\n"
67 "Unable to cast character chain\n"
68 "`" +
69 m_value + "' to type <" + m_type + ">.\n";
70 m_message = sb.toString();
71 setCollective(true);
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
78CaseOptionException(const String& where, const String& message, bool is_collective)
79: Exception("CaseOptionException", where)
80, m_message(message)
81{
82 setCollective(is_collective);
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
89CaseOptionException(const TraceInfo& where, const String& message, bool is_collective)
90: Exception("CaseOptionException", where)
91, m_message(message)
92{
93 setCollective(is_collective);
94}
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
100CaseOptionException(const CaseOptionException& rhs) ARCANE_NOEXCEPT
101: Exception(rhs)
102, m_node_name(rhs.m_node_name)
103, m_parent(rhs.m_parent)
104, m_value(rhs.m_value)
105, m_type(rhs.m_type)
106, m_message(rhs.m_message)
107{
108}
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
112
113CaseOptionException::
114~CaseOptionException() ARCANE_NOEXCEPT
115{
116}
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
122explain(std::ostream& m) const
123{
124 m << m_message << '\n';
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
130} // namespace Arcane
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
Exception related to the dataset.
CaseOptionException(const String &where, const String &node_name, const XmlNode &parent, const String &value, const String &type)
Exception when a dataset option is not valid.
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)
void setCollective(bool v)
Sets the collective state of the expression.
Unicode character string constructor.
String toString() const
Returns the constructed character string.
Node of a DOM tree.
Definition XmlNode.h:51
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --