Skip to main content

to_throw_message

Method of AlephExpectation.

Overloads

NameDescription
to_throw_message(const string message, const Map options) -> voidRecords a failure unless the expected action throws a matching message.
to_throw_message(const string message) -> voidRecords a failure unless the expected action throws a matching message.

to_throw_message(const string message, const Map options) -> void

Records a failure unless the expected action throws a matching message.

Parameters

  • message: Substring that must appear in the thrown exception message.
  • options: Optional matcher options.
    • message (String): Custom failure message to record when the matcher fails.
    • stop (Bool): Stops collecting further expectations in the current test when this matcher fails.
    • strict (Bool): Require the trimmed thrown message to equal message instead of containing it.

Returns

Nothing. Failed expectations are collected in the active test result.

Example


expect(fun[]() { throw(RuntimeError("boom")) }).to_throw_message("Error: \"boom\"", ["strict": true])

to_throw_message(const string message) -> void

Records a failure unless the expected action throws a matching message.

Parameters

  • message: Substring that must appear in the thrown exception message.

Returns

Nothing. Failed expectations are collected in the active test result.

Example


expect(fun[]() { throw(RuntimeError("boom")) }).to_throw_message("boom")