PyTorch
Loading...
Searching...
No Matches
Public Member Functions | List of all members
c10::Error Class Reference

The primary ATen error class. More...

#include <Exception.h>

Inheritance diagram for c10::Error:
c10::DistBackendError c10::EnforceFiniteError c10::IndexError c10::LinAlgError c10::NotImplementedError c10::OnnxfiBackendSystemError c10::OutOfMemoryError c10::TypeError c10::ValueError

Public Member Functions

 Error (SourceLocation source_location, std::string msg)
 
 Error (const char *file, const uint32_t line, const char *condition, const std::string &msg, const std::string &backtrace, const void *caller=nullptr)
 
 Error (std::string msg, std::string backtrace, const void *caller=nullptr)
 
void add_context (std::string msg)
 
const std::string & msg () const
 
const std::vector< std::string > & context () const
 
const std::string & backtrace () const
 
const char * what () const noexcept override
 Returns the complete error message, including the source location. More...
 
const void * caller () const noexcept
 
const char * what_without_backtrace () const noexcept
 Returns only the error message string, without source location. More...
 

Detailed Description

The primary ATen error class.

Provides a complete error message with source location information via what(), and a more concise message via what_without_backtrace(). Don't throw this directly; use TORCH_CHECK/TORCH_INTERNAL_ASSERT instead.

NB: c10::Error is handled specially by the default torch to suppress the backtrace, see torch/csrc/Exceptions.h

Constructor & Destructor Documentation

◆ Error() [1/3]

c10::Error::Error ( SourceLocation  source_location,
std::string  msg 
)

◆ Error() [2/3]

c10::Error::Error ( const char *  file,
const uint32_t  line,
const char *  condition,
const std::string &  msg,
const std::string &  backtrace,
const void *  caller = nullptr 
)

◆ Error() [3/3]

c10::Error::Error ( std::string  msg,
std::string  backtrace,
const void *  caller = nullptr 
)

Member Function Documentation

◆ add_context()

void c10::Error::add_context ( std::string  msg)

◆ backtrace()

const std::string & c10::Error::backtrace ( ) const
inline

◆ caller()

const void * c10::Error::caller ( ) const
inlinenoexcept

◆ context()

const std::vector< std::string > & c10::Error::context ( ) const
inline

◆ msg()

const std::string & c10::Error::msg ( ) const
inline

◆ what()

const char * c10::Error::what ( ) const
inlineoverridenoexcept

Returns the complete error message, including the source location.

The returned pointer is invalidated if you call add_context() on this object.

◆ what_without_backtrace()

const char * c10::Error::what_without_backtrace ( ) const
inlinenoexcept

Returns only the error message string, without source location.

The returned pointer is invalidated if you call add_context() on this object.


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