Loading [MathJax]/extensions/TeX/AMSsymbols.js
 deal.II version GIT relicensing-2836-g362046b457 2025-03-13 15:40:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
exceptions.cc
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2016 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#include <deal.II/base/config.h>
16
18
19#include <iostream>
20
21#ifdef DEAL_II_WITH_PETSC
22# include <petscsys.h>
23#endif // DEAL_II_WITH_PETSC
24
25
27
28namespace LACExceptions
29{
30 ExcPETScError::ExcPETScError(const int error_code)
31 : error_code(error_code)
32 {}
33
34 void
35 ExcPETScError::print_info(std::ostream &out) const
36 {
37 out << "deal.II encountered an error while calling a PETSc function."
38 << std::endl;
39#ifdef DEAL_II_WITH_PETSC
40 // PetscErrorMessage changes the value in a pointer to refer to a
41 // statically allocated description of the current error message.
42 const char *petsc_message;
43 const PetscErrorCode ierr =
44 PetscErrorMessage(static_cast<PetscErrorCode>(error_code),
45 &petsc_message,
46 /*specific=*/nullptr);
47 if (ierr == 0 && petsc_message != nullptr)
48 {
49 out << "The description of the error provided by PETSc is \""
50 << petsc_message << "\"." << std::endl;
51 }
52 else
53 {
54 out
55 << "PETSc was not able to determine a description for this particular error code."
56 << std::endl;
57 }
58#endif // DEAL_II_WITH_PETSC
59 out << "The numerical value of the original error code is " << error_code
60 << '.' << std::endl;
61 }
62} // namespace LACExceptions
63
virtual void print_info(std::ostream &out) const override
Definition exceptions.cc:35
ExcPETScError(const int error_code)
Definition exceptions.cc:30
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:40
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:41