aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
exceptions_inl.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41#pragma once
42
46
47namespace gum {
48
49
50 GUM_NODISCARD INLINE const char* Exception::what() const noexcept { return what_.c_str(); }
51
52 GUM_NODISCARD INLINE std::string Exception::errorContent() const { return msg_; }
53
54 GUM_NODISCARD INLINE std::string Exception::errorType() const { return type_; }
55
56 GUM_NODISCARD INLINE std::string Exception::errorCallStack() const { return callstack_; }
57
58 INLINE
59 SyntaxError::SyntaxError(const std::string& aMsg,
60 std::string aFilename,
61 Size nol,
62 Size noc,
63 const std::string& aType) :
64 IOError(aMsg, aType), noLine_(nol), noCol_(noc), filename_(std::move(aFilename)) {
65#ifdef GUM_FOR_SWIG
66 what_ = "[pyAgrum] " + msg_;
67#else // GUM_FOR_SWIG
68 std::ostringstream error_stream;
69 error_stream << type_ << ":" << std::endl;
70 error_stream << filename() << ":" << line() << "," << col() << " : " << msg_;
71 what_ = error_stream.str();
72#endif // GUM_FOR_SWIG
73 }
74
75 GUM_NODISCARD INLINE Size SyntaxError::col() const { return noCol_; }
76
77 GUM_NODISCARD INLINE Size SyntaxError::line() const { return noLine_; }
78
79 GUM_NODISCARD INLINE std::string SyntaxError::filename() const { return filename_; }
80
81} // namespace gum
std::string callstack_
Definition exceptions.h:126
std::string msg_
Definition exceptions.h:124
GUM_NODISCARD std::string errorCallStack() const
Returns the error call stack.
std::string what_
Definition exceptions.h:127
GUM_NODISCARD std::string errorContent() const
Returns the message content.
GUM_NODISCARD const char * what() const noexcept override
GUM_NODISCARD std::string errorType() const
Returns the error type.
std::string type_
Definition exceptions.h:125
Exception : input/output problem.
aGrUM's exceptions
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
aGrUM's inline/outline selection
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
Provides basic types used in aGrUM.
#define GUM_NODISCARD
Definition types.h:61