libMesh
Public Member Functions | Public Attributes | List of all members
libMesh::PetscSolverException Class Reference

A specialization of the SolverException class for PETSc. More...

#include <petsc_solver_exception.h>

Inheritance diagram for libMesh::PetscSolverException:
[legend]

Public Member Functions

 PetscSolverException (int error_code_in)
 
virtual const char * what () const noexcept override
 Override the what() function to provide a generic error message. More...
 

Public Attributes

int error_code
 The error code generated by the solver. More...
 
std::string what_message
 string which holds the message built in the constructor. More...
 

Detailed Description

A specialization of the SolverException class for PETSc.

Definition at line 50 of file petsc_solver_exception.h.

Constructor & Destructor Documentation

◆ PetscSolverException()

libMesh::PetscSolverException::PetscSolverException ( int  error_code_in)
inline

Definition at line 53 of file petsc_solver_exception.h.

References libMesh::SolverException::error_code, libMesh::libmesh_ignore(), and libMesh::SolverException::what_message.

53  :
54  SolverException(error_code_in)
55  {
56  const char * text;
57 #if PETSC_VERSION_LESS_THAN(3,25,0)
58  char * specific;
59 #else
60  const char * specific;
61 #endif
62  auto ierr = PetscErrorMessage(cast_int<PetscErrorCode>(error_code), &text, &specific);
63  // This is one scenario where we ignore the error code
64  // returned by a PETSc function :)
65  libmesh_ignore(ierr);
66 
67  // Usually the "specific" error message string is more useful than
68  // the generic text corresponding to the error_code, since many
69  // SETERRQ calls just use error_code == 1
70  if (specific)
71  what_message = std::string(specific);
72  else if (text)
73  what_message = std::string(text);
74  }
SolverException(int error_code_in)
int error_code
The error code generated by the solver.
std::string what_message
string which holds the message built in the constructor.
void libmesh_ignore(const Args &...)

Member Function Documentation

◆ what()

virtual const char* libMesh::SolverException::what ( ) const
inlineoverridevirtualnoexceptinherited

Override the what() function to provide a generic error message.

Definition at line 179 of file libmesh_exceptions.h.

References libMesh::SolverException::what_message.

180  {
181  // std::string::c_str() is noexcept in C++11, so it's safe to call
182  // in what() because it can't throw.
183  return what_message.c_str();
184  }
std::string what_message
string which holds the message built in the constructor.

Member Data Documentation

◆ error_code

int libMesh::SolverException::error_code
inherited

The error code generated by the solver.

Definition at line 189 of file libmesh_exceptions.h.

Referenced by PetscSolverException(), and libMesh::SolverException::SolverException().

◆ what_message

std::string libMesh::SolverException::what_message
inherited

string which holds the message built in the constructor.

Definition at line 194 of file libmesh_exceptions.h.

Referenced by PetscSolverException(), libMesh::SolverException::SolverException(), and libMesh::SolverException::what().


The documentation for this class was generated from the following file: