@jenova-marie/ts-rust-result - v2.2.18
    Preparing search index...

    Function err

    • Creates an error result with the given error.

      Type Parameters

      • E = Error

        The type of the error

      Parameters

      • error: E

        The error object to wrap in an error result

      Returns Result<never, E>

      A Result object representing failure with the given error

      const result = err(new Error("Something went wrong"))
      if (!result.ok) {
      console.log(result.error.message) // "Something went wrong"
      }

      // With DomainError (2.1.0+)
      import { fileNotFound } from '@jenova-marie/ts-rust-result/errors'
      const result = err(fileNotFound('/missing.txt'))
      // result.error is typed as FileNotFoundError