This file defines two main structs/classes used in nix error handling. More...
#include "suggestions.hh"
#include "fmt.hh"
#include <cstring>
#include <list>
#include <memory>
#include <optional>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Go to the source code of this file.
Classes | |
struct | nix::LinesOfCode |
struct | nix::Trace |
struct | nix::ErrorInfo |
class | nix::BaseError |
class | nix::SysError |
Macros | |
#define | MakeError(newClass, superClass) |
#define | unreachable() |
Typedefs | |
using | nix::NativeSysError |
Enumerations | |
enum | Verbosity { lvlError = 0 , lvlWarn , lvlNotice , lvlInfo , lvlTalkative , lvlChatty , lvlDebug , lvlVomit } |
enum struct | nix::TracePrint { Default , Always } |
Functions | |
void | nix::printCodeLines (std::ostream &out, const std::string &prefix, const Pos &errPos, const LinesOfCode &loc) |
std::strong_ordering | nix::operator<=> (const Trace &lhs, const Trace &rhs) |
std::ostream & | nix::showErrorInfo (std::ostream &out, const ErrorInfo &einfo, bool showTrace) |
nix::MakeError (Error, BaseError) | |
nix::MakeError (UsageError, Error) | |
nix::MakeError (UnimplementedError, Error) | |
nix::MakeError (SystemError, Error) | |
void | nix::throwExceptionSelfCheck () |
void | nix::panic (std::string_view msg) |
void | nix::panic (const char *file, int line, const char *func) |
This file defines two main structs/classes used in nix error handling.
ErrorInfo provides a standard payload of error information, with conversion to string happening in the logger rather than at the call site.
BaseError is the ancestor of nix specific exceptions (and Interrupted), and contains an ErrorInfo.
ErrorInfo structs are sent to the logger as part of an exception, or directly with the logError or logWarning macros. See libutil/tests/logging.cc for usage examples.
#define MakeError | ( | newClass, | |
superClass ) |
#define unreachable | ( | ) |
Print a basic error message with source position and abort().
using nix::NativeSysError |
Convenience alias for when we use a errno
-based error handling function on Unix, and GetLastError()
-based error handling on on Windows.
|
strong |
nix::MakeError | ( | SystemError | , |
Error | ) |
To use in catch-blocks.
An arbitrarily defined value comparison for the purpose of using traces in the key of a sorted container.
Print a basic error message with source position and abort(). Use the unreachable() macro to call this.
void nix::panic | ( | std::string_view | msg | ) |
Print a message and abort().
void nix::throwExceptionSelfCheck | ( | ) |
Throw an exception for the purpose of checking that exception handling works; see 'initLibUtil()'.