Skip to main content

Function: handlePortCheckError()

handlePortCheckError(error: unknown, host: string, port: number): PortCheckErrorResult

Defined in: electron/services/monitoring/utils/portErrorHandling.ts:169

Normalizes errors from port checks into a standardized result structure for frontend consumption.

Parameters

error

unknown

The error thrown during port checking. May be any type, but typically an ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error or PortCheckError.

host

string

The hostname or IP address being checked.

port

number

The port number being checked.

Returns

PortCheckErrorResult

A PortCheckErrorResult containing error details, standardized message, timing, and status.

Remarks

Converts any error thrown during a port check into a PortCheckErrorResult object. If the error is a PortCheckError, its response time is preserved; otherwise, responseTime is set to -1. Logs debug information in development mode for diagnostics.

Example

try {
// ...port check logic...
} catch (err) {
const result = handlePortCheckError(err, "example.com", 443);
// result.status === "down"
}

See