![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <system-error.hh>
Public Types | |
| using | NativeCode = std::remove_cvref_t<decltype(std::declval<Fields &>().*field)> |
Public Member Functions | |
| template<typename... Args> | |
| NativeCodeSystemError (NativeCode code, Args &&... args) | |
| NativeCodeSystemError (NativeCode code, const HintFmt &hf) | |
| template<typename... Args> | |
| NativeCodeSystemError (Args &&... args) | |
| NativeCodeSystemError (auto &&mkHintFmt) | |
| Public Member Functions inherited from nix::SystemError | |
| 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 |
Additional Inherited Members | |
| Protected Member Functions inherited from nix::SystemError | |
| 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 |
| Protected Attributes inherited from nix::BaseError | |
| ErrorInfo | err |
| std::optional< std::string > | what_ |
Shared, reusable implementation for a SystemError for a particular kind of native error code.
This is used for SysError (for errno) and windows::WinError (for GetLastError()). Like other errors, they derive from it through CloneableError, e.g. CloneableError<SysError, NativeCodeSystemError<SysErrorFields, &SysErrorFields::errNo>>, and inherit its constructors.
Fields must provide these static methods:
Together, ambientError and toErrorCode are for checking what went wrong, e.g. by comparing with std::errc, where that is an expected outcome rather than an exception, without constructing an error just to call SystemError::is. If it does need throwing after all, pass the code to the constructor taking one.
The native code itself is stored in Fields::*field, e.g. SysError::errNo or WinError::lastError. Each kind of code keeps its own name, so that code using one where the other is meant, e.g. comparing a WinError code with an errno value, does not mistakenly compile because of bad implicit conversions.
The field is in a separate base, Fields, rather than in the derived error class itself, since that class's own members are not yet constructed when this class's constructors set it.
|
inline |
Construct using the explicitly-provided error code, which Fields::renderError describes in the message.
|
inline |
Construct using the explicitly-provided error code, which Fields::renderError describes in the message.
Unlike above, the HintFmt already exists rather than being made on the spot.
|
inline |
Construct using the ambient error code.
Be sure to not perform another operation that may change it before calling this constructor!
|
inline |
Construct using the ambient error code and a function that produces a HintFmt. The error code is read first, then the function is called, so the function is safe to change it.