"use strict";
/*
 * Copyright 2024 Amazon.com, Inc. or its affiliates. All rights reserved.
 *
 * AMAZON PROPRIETARY/CONFIDENTIAL
 *
 * You may not use this file except in compliance with the terms and
 * conditions set forth in the accompanying LICENSE.TXT file.
 *
 * THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
 * DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
 * IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TryAgainError = exports.NotConnectedError = exports.OutOfResourceError = exports.OutOfMemoryError = exports.NotFoundError = exports.NoPermissionError = exports.NotSupportedError = exports.InProgressError = exports.InvalidArgumentError = exports.TimeOutError = exports.AccessoryError = void 0;
const AccClientTypes_1 = require("./AccClientTypes");
/**
 * Base class for all Accessory errors with message defined in {AccessoryControlStatus}
 * or other Unrecognized error.
 * Explicitly thrown when a status returned from native layer doesn't have a specific
 * Error type defined for in rest of this file. This might happen when unexpected status
 * received. Unlikely but the possibility still exist.
 *
 * @extends Error
 * @param {number} status - The error code.
 */
class AccessoryError extends Error {
    constructor(status) {
        if (Object.values(AccClientTypes_1.AccessoryControlStatus).includes(status)) {
            super(AccClientTypes_1.AccessoryControlStatus[status]);
        }
        else {
            super('Unrecognized error: ' + status);
        }
        this.name = 'AccessoryError';
    }
}
exports.AccessoryError = AccessoryError;
/**
 * Error class representing a timeout error with message 'TIMEOUT'
 * @extends AccessoryError
 */
class TimeOutError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.TIMEOUT);
        this.name = 'TimeOutError';
    }
}
exports.TimeOutError = TimeOutError;
/**
 * Error class representing an invalid argument error with message 'BAD_PARAMS'.
 * @extends AccessoryError
 */
class InvalidArgumentError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.BAD_PARAMS);
        this.name = 'InvalidArgumentError';
    }
}
exports.InvalidArgumentError = InvalidArgumentError;
/**
 * Error class representing an in-progress error with message 'IN_PROGRESS'.
 * @extends AccessoryError
 */
class InProgressError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.IN_PROGRESS);
        this.name = 'InProgressError';
    }
}
exports.InProgressError = InProgressError;
/**
 * Error class representing a not-supported error with message 'NOT_SUPPORTED'.
 * @extends AccessoryError
 */
class NotSupportedError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.NOT_SUPPORTED);
        this.name = 'NotSupportedError';
    }
}
exports.NotSupportedError = NotSupportedError;
/**
 * Error class representing a no-permission error with message 'NOT_PERMITTED'.
 * Refer to @privilege of each interfaces for required permission.
 *
 * @extends AccessoryError
 */
class NoPermissionError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.NOT_PERMITTED);
        this.name = 'NoPermissionError';
    }
}
exports.NoPermissionError = NoPermissionError;
/**
 * Error class representing a not-found error with message 'NOT_FOUND'.
 * @extends AccessoryError
 */
class NotFoundError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.NOT_FOUND);
        this.name = 'NotFoundError';
    }
}
exports.NotFoundError = NotFoundError;
/**
 * Error class representing an out-of-memory error with message 'NO_MEMORY'.
 * @extends AccessoryError
 */
class OutOfMemoryError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.NO_MEMORY);
        this.name = 'OutOfMemoryError';
    }
}
exports.OutOfMemoryError = OutOfMemoryError;
/**
 * Error class representing an out-of-resource error with message 'NO_RESOURCE'.
 * @extends AccessoryError
 */
class OutOfResourceError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.NO_RESOURCE);
        this.name = 'OutOfResourceError';
    }
}
exports.OutOfResourceError = OutOfResourceError;
/**
 * Error class representing an connection error with message 'NOT_CONNECTED'.
 * @extends AccessoryError
 */
class NotConnectedError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.NOT_CONNECTED);
        this.name = 'NotConnectedError';
    }
}
exports.NotConnectedError = NotConnectedError;
/**
 * Error class representing an try again error with message 'TRY_AGAIN'.
 * @extends AccessoryError
 */
class TryAgainError extends AccessoryError {
    constructor() {
        super(AccClientTypes_1.AccessoryControlStatus.TRY_AGAIN);
        this.name = 'TryAgainError';
    }
}
exports.TryAgainError = TryAgainError;
