query
On this page

assertMsg

lib.asserts.assertMsg

Docs pulled from | This Revision | about 1 hour ago


Throw if pred is false, else return pred. Intended to be used to augment asserts with helpful error messages.

Inputs

pred

Predicate that needs to succeed, otherwise msg is thrown

msg

Message to throw in case pred fails

Type

assertMsg :: Bool -> String -> Bool

Examples

lib.asserts.assertMsg usage example

assertMsg false "nope"
stderr> error: nope
assert assertMsg ("foo" == "bar") "foo is not bar, silly"; ""
stderr> error: foo is not bar, silly

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

assertMsg = pred: msg: pred || builtins.throw msg;