/**
 * Copyright schukai GmbH and contributors 2022. All Rights Reserved.
 * Node module: @schukai/monster
 * This file is licensed under the AGPLv3 License.
 * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
 */


import {internalSymbol} from "../../../constants.mjs";

export {WriteError}

/**
 * Error message for API requests with extension of request and validation.
 * 
 * @license AGPLv3
 * @since 1.24.0
 * @copyright schukai GmbH
 * @memberOf Monster.Data.Datasource.RestAPI
 * @summary the error is thrown by the rest api in case of error
 */
class WriteError extends Error {
    /**
     *
     * @param {string} message
     * @param {Response} response
     */
    constructor(message, response, validation) {
        super(message);
        this[internalSymbol] = {
            response: response,
            validation: validation
        };
    }

    /**
     * @return {Response}
     */
    getResponse() {
        return this[internalSymbol]['response']
    }

    /**
     * @return {Object}
     */
    getValidation() {
        return this[internalSymbol]['validation']
    }
}