Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
SignalException.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* SignalException.cc (C) 2000-2016 */
9/* */
10/* Exception lorsqu'un signal survient. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/Iostream.h"
17#include "arcane/utils/SignalException.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22ARCANE_BEGIN_NAMESPACE
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27SignalException::
28SignalException(const String& where,eSignalType st,int signal_number)
29: Exception("Signal",where)
30, m_signal_type(st)
31, m_signal_number(signal_number)
32{
33}
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38SignalException::
39SignalException(const String& where,const StackTrace& stack_trace,
40 eSignalType st,int signal_number)
41: Exception("Signal",where,stack_trace)
42, m_signal_type(st)
43, m_signal_number(signal_number)
44{
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50SignalException::
51SignalException(const SignalException& ex)
52: Exception(ex)
53, m_message(ex.m_message)
54, m_signal_type(ex.m_signal_type)
55, m_signal_number(ex.m_signal_number)
56{
57}
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62void SignalException::
63explain(std::ostream& m) const
64{
65 if (!m_message.null())
66 m << "Message: " << m_message << '\n';
67
68 m << "A fatal signal has occurred: ";
69 switch(m_signal_type){
70 case ST_FloatingException:
71 m << "Floating Exception";
72 break;
73 case ST_SegmentationFault:
74 m << "Segmentation Violation";
75 break;
76 case ST_BusError:
77 m << "Bus Error";
78 break;
79 case ST_Alarm:
80 m << "Sigalarm";
81 break;
82 case ST_Unknown:
83 m << "Unknown";
84 break;
85 }
86 m << " (signal number is: " << m_signal_number << ")\n";
87}
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92SignalException::eSignalType SignalException::
93signalType() const
94{
95 return m_signal_type;
96}
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101int SignalException::
102signalNumber() const
103{
104 return m_signal_number;
105}
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110ARCANE_END_NAMESPACE
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114