Rac. Exception

Throwable object to report errors, and container of convenience functions to create these.

The static functions create either Exception or Error instances, since different environments respond differentely to these throws. For more details see buildsErrors.

Constructor

new Exception(name, message)

Creates a new Exception instance.

Parameters:
Name Type Description
name String

The name of the exception

message String

The message of the exception

Members

(static) buildsErrors :Boolean

When true the convenience static functions of this class will build Error objects, otherwise Exception objects are built.

Defaults to false for browser use: throwing an Exception in chrome displays the error stack using source-maps when available. In contrast throwing an Error object displays the error stack relative to the bundled file, which is harder to read.

Used as true for test runs in Jest: throwing an Error will be reported in the test report, while throwing a custom object (like Exception) within a matcher results in the expectation hanging indefinitely.

Default Value:
  • false

Methods

(static) named(name) → {Rac.Exception~namedFactory}

Returns a factory function that builds throwable objects with the given name.

Parameters:
Name Type Description
name String

The name for the produced throwable objects

Example
let factory = Rac.Exception.named('NotAPangram')
factory.exceptionName // returns 'NotAPangram'
factory('Waltz, bad nymph').toString()
// returns: 'Exception:NotAPangram - Waltz, bad nymph'

toString() → {String}

Returns a string representation intended for human consumption.

Example
(new Rac.Exception('NotAPangram', 'Waltz, bad nymph')).toString()
// Returns: 'Exception:NotAPangram - Waltz, bad nymph'

Type Definitions

namedFactory(message) → {Exception|Error}

Factory function that returns a throwable object with the given message.

Properties:
Name Type Description
exceptionName String

The name for the produced throwable objects

Parameters:
Name Type Description
message String

The message for the produced throwable object.