Flox Package Database 1
CRUD Operations on Nix Package Metadata
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Enumerations | Functions
exceptions.hh File Reference

Definitions of various std::exception children used for throwing errors with nice messages and typed discrimination. More...

#include <nix/nixexpr.hh>
#include <nlohmann/json.hpp>
#include <optional>
#include <stdexcept>
#include <string>

Go to the source code of this file.

Classes

class  flox::FloxException
 
class  flox::NixEvalException
 A nix::EvalError was encountered.
More...
 

Namespaces

namespace  flox
 Interfaces for use by flox.
 

Macros

#define FLOX_DEFINE_EXCEPTION(NAME, ERROR_CODE, CATEGORY_MSG)
 Generate a class definition with an error code and category message.
 

Enumerations

enum  flox::error_category {
  flox::EC_OKAY = 0 , flox::EC_FAILURE = 1 , flox::EC_FLOX_EXCEPTION = 100 , flox::EC_INVALID_ARG ,
  flox::EC_INVALID_MANIFEST_DESCRIPTOR , flox::EC_INVALID_PKG_QUERY_ARG , flox::EC_INVALID_REGISTRY , flox::EC_INVALID_MANIFEST_FILE ,
  flox::EC_NIX , flox::EC_NIX_EVAL , flox::EC_NIX_LOCK_FLAKE , flox::EC_PACKAGE_INIT ,
  flox::EC_PARSE_MANIFEST_DESCRIPTOR_RAW , flox::EC_PARSE_RESOLVED , flox::EC_PARSE_SEARCH_QUERY , flox::EC_PKG_DB ,
  flox::EC_SQLITE3 , flox::EC_JSON , flox::EC_TOML_TO_JSON , flox::EC_YAML_TO_JSON ,
  flox::EC_INVALID_LOCKFILE , flox::EC_INVALID_HASH , flox::EC_RESOLUTION_FAILURE , flox::EC_ENVIRONMENT_MIXIN
}
 

Functions

void flox::to_json (nlohmann::json &jto, const FloxException &err)
 Convert a flox::FloxException to a JSON object.
 

Detailed Description

Definitions of various std::exception children used for throwing errors with nice messages and typed discrimination.

Macro Definition Documentation

◆ FLOX_DEFINE_EXCEPTION

#define FLOX_DEFINE_EXCEPTION (   NAME,
  ERROR_CODE,
  CATEGORY_MSG 
)
Value:
class NAME : public FloxException \
{ \
public: \
\
NAME() : FloxException( CATEGORY_MSG, std::nullopt, std::nullopt ) {} \
\
explicit NAME( std::string_view contextMsg ) \
: FloxException( ( CATEGORY_MSG ), \
std::string( contextMsg ), \
std::nullopt ) \
{} \
\
explicit NAME( std::string_view contextMsg, std::string_view caughtMsg ) \
: FloxException( ( CATEGORY_MSG ), \
std::string( contextMsg ), \
std::string( caughtMsg ) ) \
{} \
\
[[nodiscard]] error_category \
getErrorCode() const noexcept override \
{ \
return ( ERROR_CODE ); \
} \
\
[[nodiscard]] std::string_view \
getCategoryMessage() const noexcept override \
{ \
return ( CATEGORY_MSG ); \
} \
};

Generate a class definition with an error code and category message.

The resulting class will have NAME(), NAME( contextMsg ), and NAME( contextMsg, caughtMsg ) constructors available.