tguard-js
    Preparing search index...

    Function isErrorLike

    • Determines whether the provided value is error-like.

      Parameters

      • x: unknown

        The value to be checked.

      Returns x is { message: string }

      true if the value is error-like, otherwise false.

      A value is considered error-like if it is an object containing a string message property.

      This is useful when handling errors from external sources where thrown values may not be actual Error instances.

      Value Result
      new Error('msg') true
      { message: 'msg' } true
      { message: 123 } false
      'error' false

      1.0