Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
diagnose.hh File Reference
#include <optional>
#include "nix/util/ansicolor.hh"
#include "nix/util/configuration.hh"
#include "nix/util/error.hh"
#include "nix/util/logging.hh"

Go to the source code of this file.

Enumerations

enum struct  nix::Diagnose { Ignore , Warn , Fatal }

Functions

template<typename F>
void nix::diagnose (const Setting< Diagnose > &setting, const F &mkError)

Enumeration Type Documentation

◆ Diagnose

enum struct nix::Diagnose
strong

Diagnostic level for deprecated or non-portable language features.

Enumerator
Ignore 

Ignore the feature without any diagnostic.

Warn 

Warn when the feature is used, but allow it.

Fatal 

Treat the feature as a fatal error.

Function Documentation

◆ diagnose()

template<typename F>
void nix::diagnose ( const Setting< Diagnose > & setting,
const F & mkError )

Check a diagnostic setting and either do nothing, log a warning, or throw an error.

The setting name is automatically appended to the error message.

Parameters
settingThe diagnostic setting to check
mkErrorA function that takes a bool (true if fatal, false if warning) and returns an optional error to throw (or warn with). Only called if level is not Ignore. If the function returns std::nullopt, no diagnostic is emitted.
Exceptions
Theerror returned by mkError if level is Fatal and mkError returns a value