Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
CaseOptionError.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/* CaseOptionError.cc (C) 2000-2023 */
9/* */
10/* Error in the dataset. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/Iostream.h"
15#include "arcane/utils/StringBuilder.h"
16
17#include "arcane/core/CaseOptionError.h"
18#include "arcane/core/ICaseDocument.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
30CaseOptionError(const TraceInfo& where, const String& node_name,
31 const String& message, bool is_collective)
32: m_func_info(where)
33, m_node_name(node_name)
34, m_message(message)
35, m_is_collective(is_collective)
36{
37}
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
44 const TraceInfo& where,
45 const String& node_name,
46 const XmlNode& parent)
47{
48 String full_node_name = parent.xpathFullName() + "/" + node_name;
49 String message = "Element or attribute missing";
50
51 document->addError(CaseOptionError(where, full_node_name, message, true));
52}
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
59 const TraceInfo& where, const String& node_name,
60 const XmlNode& parent, const String& value,
61 const String& type_name)
62{
63 String full_node_name = parent.xpathFullName() + "/" + node_name;
64
65 String message = String::format("Invalid value. Impossible to convert the string"
66 " '{0}' to the type '{1}'.",
67 value, type_name);
68
69 document->addError(CaseOptionError(where, full_node_name, message, true));
70}
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
77 const TraceInfo& where, const String& node_name,
78 const XmlNode& parent, const String& value,
79 const String& type_name, StringConstArrayView valid_values)
80{
81 String full_node_name = parent.xpathFullName() + " /" + node_name;
82
83 String message = String::format("Invalid value. Impossible to convert the string"
84 " '{0}' to the type '{1}' (admissible values: {2}). ",
85 value,
86 type_name, String::join(", ", valid_values));
87 message = message + "\nSpaces at the beginning and the end of a string matter.\nPlease check that there is none.";
88 document->addError(CaseOptionError(where, full_node_name, message, true));
89}
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
96 const TraceInfo& where, const String& node_name,
97 const String& message, bool is_collective)
98{
99 document->addError(CaseOptionError(where, node_name, message, is_collective));
100}
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
107 const TraceInfo& where, const String& node_name,
108 const String& message, bool is_collective)
109{
110 document->addWarning(CaseOptionError(where, node_name, message, is_collective));
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116} // End namespace Arcane
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
static void addWarning(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const String &message, bool is_collective=false)
Generic error.
static void addError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const String &message, bool is_collective=false)
Generic error.
CaseOptionError(const TraceInfo &where, const String &node_name, const String &message, bool is_collective=false)
Generic error.
static void addInvalidTypeError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent, const String &value, const String &expected_type)
Error when a dataset value is not of the correct type. This error is collective.
static void addOptionNotFoundError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent)
Error when a dataset option is not found. This error is collective.
Interface of a part of a dataset.
virtual void addError(const CaseOptionError &case_error)=0
Adds an error to the dataset.
virtual void addWarning(const CaseOptionError &case_error)=0
Adds a warning to the dataset.
Node of a DOM tree.
Definition XmlNode.h:51
String xpathFullName() const
XPath name of the node with its ancestors.
Definition XmlNode.cc:152
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ConstArrayView< String > StringConstArrayView
C equivalent of a 1D array of strings.
Definition UtilsTypes.h:492