node-switchbot
    Preparing search index...

    Class ErrorUtils

    Enhanced error handling utilities.

    Index

    Constructors

    Methods

    • Creates a command error with context.

      Parameters

      • command: string

        The command that failed

      • deviceId: string

        The device ID

      • Optionalcause: Error

        The underlying cause

      Returns Error

      A descriptive command error

    • Creates a connection error with context.

      Parameters

      • deviceId: string

        The device ID that failed to connect

      • Optionalcause: Error

        The underlying cause of the connection failure

      Returns Error

      A descriptive connection error

    • Creates a timeout error with context.

      Parameters

      • operation: string

        The operation that timed out

      • timeoutMs: number

        The timeout duration in milliseconds

      Returns Error

      A descriptive timeout error

    • Wraps an async operation with timeout and enhanced error handling.

      Type Parameters

      • T

      Parameters

      • operation: Promise<T>

        The async operation to wrap

      • timeoutMs: number

        Timeout in milliseconds

      • operationName: string

        Name of the operation for error messages

      Returns Promise<T>

      Promise that resolves with the operation result or rejects with timeout