UNPKG

827 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.HapStatusError = void 0;
4const HAPServer_1 = require("../HAPServer");
5/**
6 * Throws a HAP status error that is sent back to HomeKit.
7 *
8 * @example
9 * ```ts
10 * throw new HapStatusError(HAPStatus.OPERATION_TIMED_OUT);
11 * ```
12 *
13 * @group Utils
14 */
15class HapStatusError extends Error {
16 hapStatus;
17 constructor(status) {
18 super("HAP Status Error: " + status);
19 Object.setPrototypeOf(this, HapStatusError.prototype);
20 if ((0, HAPServer_1.IsKnownHAPStatusError)(status)) {
21 this.hapStatus = status;
22 }
23 else {
24 this.hapStatus = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
25 }
26 }
27}
28exports.HapStatusError = HapStatusError;
29//# sourceMappingURL=hapStatusError.js.map
\No newline at end of file