query
On this page

throwIfNot

lib.throwIfNot

Docs pulled from | This Revision | 43 minutes ago


Like the assert b; e expression, but with a custom error message and without the semicolon.

If true, return the identity function, r: r.

If false, throw the error message.

Calls can be juxtaposed using function application, as (r: r) a = a, so (r: r) (r: r) a = a, and so forth.

Inputs

cond

1. Function argument

msg

2. Function argument

Type

bool -> string -> a -> a

Examples

lib.trivial.throwIfNot usage example

throwIfNot (lib.isList overlays) "The overlays argument to nixpkgs must be a list."
lib.foldr (x: throwIfNot (lib.isFunction x) "All overlays passed to nixpkgs must be functions.") (r: r) overlays
pkgs
(lib.trivial.throwIfNot)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

throwIfNot = cond: msg: if cond then x: x else throw msg;