Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
ExceptionUtils.h
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#pragma once
9
10namespace Alien
11{
12namespace Exception
13{
14 class BaseException : public std::exception
15 {
16 public:
17 BaseException(const char* type, const char* msg, int line)
18 {
19 std::ostringstream oss;
20 oss << "Error type " << type << " line " << line << " : "
21 << msg;
22 this->msg = oss.str();
23 }
24
25 BaseException(const char* type, const char* msg)
26 {
27 std::ostringstream oss;
28 oss << "Error type " << type << " : " << msg;
29 this->msg = oss.str();
30 }
31
32 virtual ~BaseException() noexcept(true)
33 {
34 }
35
36 virtual const char* what() const noexcept(true)
37 {
38 return this->msg.c_str();
39 }
40
41 private:
42 std::string msg;
43 };
44
45 class NumericException : public BaseException
46 {
47 public:
48 NumericException(std::string const& msg, int line)
49 : BaseException("Numeric", msg.c_str(), line)
50 {}
51 };
52} // namespace Exception
53} // namespace Alien
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17