method Result.prototype.error
Result.prototype.error(): E

Gets the error from an Err Result.

Only call this after checking isErr(). If called on Ok, throws an error.

Examples

Example 1

const result = err(new ValidationError("Failed"));
if (result.isErr()) {
  console.log(result.error.message); // "Failed"
}

Return Type

The error value

Usage

import { Result } from "result/mod.ts";