RTCForge API Reference v1.1.1
    Preparing search index...

    Function toError

    • Coerces an arbitrary thrown value into an Error instance.

      Parameters

      • err: unknown

        The caught value, which may or may not be an Error.

      Returns Error

      err unchanged if it is already an Error; otherwise a new Error whose message is String(err).

      try {
      risky()
      } catch (e) {
      const error = toError(e) // guaranteed Error
      logger.error(error.message)
      }