Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::SystemError Class Reference

#include <system-error.hh>

Inheritance diagram for nix::SystemError:
nix::CloneableError< SystemError, Error > nix::Error nix::CloneableError< Error, BaseError > nix::BaseError nix::NativeCodeSystemError< SysErrorFields, &SysErrorFields::errNo > nix::NativeCodeSystemError< Fields, field > nix::CloneableError< SysError, NativeCodeSystemError< SysErrorFields, &SysErrorFields::errNo > > nix::SysError

Classes

struct  DisambigHintFmt
struct  DisambigVarArgs

Public Member Functions

 SystemError (std::error_code errorCode, const HintFmt &hf)
template<typename... Args>
 SystemError (std::error_code errorCode, Args &&... args)
const std::error_code ec () const &
bool is (std::errc e) const
template<std::same_as< std::errc >... Rest>
bool is (std::errc e, Rest... rest) const
Public Member Functions inherited from nix::CloneableError< SystemError, Error >
void throwClone () const override
Public Member Functions inherited from nix::BaseError
 BaseError (const BaseError &)=default
BaseError & operator= (const BaseError &)=default
BaseError & operator= (BaseError &&) noexcept=default
template<typename... Args>
 BaseError (unsigned int status, Args &&... args)
template<typename... Args>
 BaseError (const std::string &fs, Args &&... args)
template<typename... Args>
 BaseError (const Suggestions &sug, Args &&... args)
 BaseError (HintFmt hint)
 BaseError (ErrorInfo &&e)
 BaseError (const ErrorInfo &e)
std::string message () const
const char * what () const noexcept override
const std::string & msg () const
const ErrorInfo & info () const
void withExitStatus (unsigned int status)
void atPos (std::shared_ptr< const Pos > pos)
bool hasPos () const
void pushTrace (Trace trace)
template<typename... Args>
void addTrace (std::shared_ptr< const Pos > &&pos, std::string_view fs, Args &&... args)
void addTrace (std::shared_ptr< const Pos > &&pos, HintFmt hint, TracePrint print=TracePrint::Default)
bool hasTrace () const
ErrorInfo & unsafeInfo ()
void recalcWhat () const

Protected Member Functions

 SystemError (DisambigHintFmt, std::error_code errorCode, std::string_view errorDetails, const HintFmt &hf)
template<typename... Args>
 SystemError (DisambigVarArgs, std::error_code errorCode, std::string_view errorDetails, Args &&... args)
Protected Member Functions inherited from nix::BaseError
const std::string & calcWhat () const

Additional Inherited Members

Protected Attributes inherited from nix::BaseError
ErrorInfo err
std::optional< std::string > what_

Detailed Description

To use in catch-blocks. Provides a convenience method to get the portable std::error_code. Use when you want to catch and check an error condition like no_such_file_or_directory (ENOENT) without ifdefs.

Constructor & Destructor Documentation

◆ SystemError() [1/4]

nix::SystemError::SystemError ( DisambigHintFmt ,
std::error_code errorCode,
std::string_view errorDetails,
const HintFmt & hf )
inlineprotected

Protected constructor that takes a pre-built HintFmt. Use this when the error message needs to be constructed before capturing errno/GetLastError().

◆ SystemError() [2/4]

template<typename... Args>
nix::SystemError::SystemError ( DisambigVarArgs ,
std::error_code errorCode,
std::string_view errorDetails,
Args &&... args )
inlineprotected

Protected constructor for subclasses that provide their own error message. The error message is appended to the formatted hint.

◆ SystemError() [3/4]

nix::SystemError::SystemError ( std::error_code errorCode,
const HintFmt & hf )
inline

Construct with an error code. The error code's message is automatically appended to the error message.

◆ SystemError() [4/4]

template<typename... Args>
nix::SystemError::SystemError ( std::error_code errorCode,
Args &&... args )
inline

Construct with an error code. The error code's message is automatically appended to the error message.


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