Ginkgo: gko::Error Class Reference

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
gko::Error Class Reference

The Error class is used to report exceptional behaviour in library functions. More...

`#include <ginkgo/core/base/exception.hpp>`

Inheritance diagram for gko::Error:
[legend]
Collaboration diagram for gko::Error:
[legend]

## Public Member Functions
| Error (const std::string &file, int line, const std::string &what)
| Initializes an error.
virtual const char * | what () const noexcept override
| Returns a human-readable string with a more detailed description of the error.

## Detailed Description

The Error class is used to report exceptional behaviour in library functions.

Ginkgo uses C++ exception mechanism to this end, and the Error class represents a base class for all types of errors. The exact list of errors which could occur during the execution of a certain library routine is provided in the documentation of that routine, along with a short description of the situation when that error can occur. During runtime, these errors can be detected by using standard C++ try-catch blocks, and a human-readable error description can be obtained by calling the Error::what() method.

As an example, trying to compute a matrix-vector product with arguments of incompatible size will result in a DimensionMismatch error, which is demonstrated in the following program.

#include <ginkgo.h>
#include <iostream>
using namespace gko;
int main()
{
auto omp = create<OmpExecutor>();
auto A = randn_fill<matrix::Csr<float>>(5, 5, 0f, 1f, omp);
auto x = fill<matrix::Dense<float>>(6, 1, 1f, omp);
try {
auto y = apply(A, x);
} catch(Error e) {
// an error occurred, write the message to screen and exit
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
gko::Error
The Error class is used to report exceptional behaviour in library functions.
Definition exception.hpp:57
gko::Error::what
virtual const char * what() const noexcept override
Returns a human-readable string with a more detailed description of the error.
Definition exception.hpp:74
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20

## Constructor & Destructor Documentation

## ◆ Error()

gko::Error::Error | ( | const std::string & | file,
|  | int | line,
|  | const std::string & | what )
| inline

Initializes an error.

Parameters

  file | The name of the offending source file
  line | The source code line number where the error occurred
  what | The error message

References what().

Referenced by gko::AllocationError::AllocationError(), gko::BadDimension::BadDimension(), gko::BlockSizeError< IndexType >::BlockSizeError(), gko::CublasError::CublasError(), gko::CudaError::CudaError(), gko::CufftError::CufftError(), gko::CurandError::CurandError(), gko::CusparseError::CusparseError(), gko::DimensionMismatch::DimensionMismatch(), gko::HipblasError::HipblasError(), gko::HipError::HipError(), gko::HipfftError::HipfftError(), gko::HiprandError::HiprandError(), gko::HipsparseError::HipsparseError(), gko::InvalidStateError::InvalidStateError(), gko::KernelNotFound::KernelNotFound(), gko::MetisError::MetisError(), gko::MpiError::MpiError(), gko::NotCompiled::NotCompiled(), gko::NotImplemented::NotImplemented(), gko::NotSupported::NotSupported(), gko::OutOfBoundsError::OutOfBoundsError(), gko::OverflowError::OverflowError(), gko::StreamError::StreamError(), gko::UnsupportedMatrixProperty::UnsupportedMatrixProperty(), and gko::ValueMismatch::ValueMismatch().

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

- ginkgo/core/base/exception.hpp