Arcane  v4.1.1.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
arcane/src/arcane/utils/Exception.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* Exception.h (C) 2000-2025 */
9/* */
10/* Déclarations et définitions liées aux exceptions. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_EXCEPTION_H
13#define ARCANE_UTILS_EXCEPTION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/Exception.h"
18#include "arccore/base/TraceInfo.h"
20#include "arcane/utils/Atomic.h"
21
22#include <functional>
23
24// TODO: Rendre ces méthode obsolète fin 2026 et indiquer qu'il faut
25// utiliser ExceptionUtils à la place.
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36extern "C++" ARCANE_UTILS_EXPORT Integer
37arcanePrintAnyException(ITraceMng* msg,bool is_no_continue = true);
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42extern "C++" ARCANE_UTILS_EXPORT Integer
43arcanePrintStdException(const std::exception& ex,ITraceMng* msg,bool is_no_continue = true);
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48extern "C++" ARCANE_UTILS_EXPORT Integer
49arcanePrintArcaneException(const Exception& ex,ITraceMng* msg,bool is_no_continue = true);
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53/*!
54 * \ brief Appelle la fonction \a function en récupérant les éventuelles exceptions.
55 *
56 * Usage:
57 *
58 * \code
59 * arcaneCallAndCatchException([&]() { std::cout << "Hello\n"});
60 * \endcode
61 *
62 * \return 0 si aucune exception n'est récupérée et une valeur positive dans
63 * le cas contraire.
64 */
65extern "C++" ARCANE_UTILS_EXPORT Integer
66arcaneCallFunctionAndCatchException(std::function<void()> function);
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70/*!
71 * \ brief Appelle la fonction \a function et en cas d'exception appelle std::terminate().
72 */
73extern "C++" ARCANE_UTILS_EXPORT void
74arcaneCallFunctionAndTerminateIfThrow(std::function<void()> function);
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79} // End namespace Arcane
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
83
84#endif
Déclarations des types utilisés dans Arcane.
Classe de base d'une exception.
Interface du gestionnaire de traces.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
Integer arcaneCallFunctionAndCatchException(std::function< void()> function)
void arcaneCallFunctionAndTerminateIfThrow(std::function< void()> function)