@luolapeikko/ts-common
    Preparing search index...

    Function toError

    • Get or create an error from the given value, if it's not an error, it will be wrapped in an UnknownError.

      Parameters

      • err: unknown

        Error instance or error message.

      Returns UnknownError | Error

      Error instance.

      v0.1.0

      try {
      // ...
      } catch (err) {
      console.log(toError(err).message);
      }