"use strict";
/*
 * @adonisjs/drive
 *
 * (c) Harminder Virk <virk@adonisjs.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathTraversalDetectedException = exports.CannotListDirectoryException = exports.CannotGenerateUrlException = exports.CannotSetVisibilityException = exports.CannotGetMetaDataException = exports.CannotMoveFileException = exports.CannotCopyFileException = exports.CannotDeleteFileException = exports.CannotReadFileException = exports.CannotWriteFileException = void 0;
const utils_1 = require("@poppinss/utils");
/**
 * Unable to write file to the destination
 */
class CannotWriteFileException extends utils_1.Exception {
    static invoke(location, original) {
        const error = new this(`Cannot write file at location "${location}"`, 500, 'E_CANNOT_WRITE_FILE');
        error.location = location;
        error.original = original;
        return error;
    }
}
exports.CannotWriteFileException = CannotWriteFileException;
/**
 * Unable to read file from a given location
 */
class CannotReadFileException extends utils_1.Exception {
    static invoke(location, original) {
        const error = new this(`Cannot read file from location "${location}"`, 500, 'E_CANNOT_READ_FILE');
        error.location = location;
        error.original = original;
        return error;
    }
}
exports.CannotReadFileException = CannotReadFileException;
/**
 * Unable to delete file from a given location
 */
class CannotDeleteFileException extends utils_1.Exception {
    static invoke(location, original) {
        const error = new this(`Cannot delete file at location "${location}"`, 500, 'E_CANNOT_DELETE_FILE');
        error.location = location;
        error.original = original;
        return error;
    }
}
exports.CannotDeleteFileException = CannotDeleteFileException;
/**
 * Unable to copy file from source to destination
 */
class CannotCopyFileException extends utils_1.Exception {
    static invoke(source, destination, original) {
        const error = new this(`Cannot copy file from "${source}" to "${destination}"`, 500, 'E_CANNOT_COPY_FILE');
        error.source = source;
        error.destination = destination;
        error.original = original;
        return error;
    }
}
exports.CannotCopyFileException = CannotCopyFileException;
/**
 * Unable to move file from source to destination
 */
class CannotMoveFileException extends utils_1.Exception {
    static invoke(source, destination, original) {
        const error = new this(`Cannot move file from "${source}" to "${destination}"`, 500, 'E_CANNOT_MOVE_FILE');
        error.source = source;
        error.destination = destination;
        error.original = original;
        return error;
    }
}
exports.CannotMoveFileException = CannotMoveFileException;
/**
 * Unable to get file metadata
 */
class CannotGetMetaDataException extends utils_1.Exception {
    static invoke(location, operation, original) {
        const error = new this(`Unable to retrieve the "${operation}" for file at location "${location}"`, 500, 'E_CANNOT_GET_METADATA');
        error.location = location;
        error.operation = operation;
        error.original = original;
        return error;
    }
}
exports.CannotGetMetaDataException = CannotGetMetaDataException;
/**
 * Unable to set visibility
 */
class CannotSetVisibilityException extends utils_1.Exception {
    static invoke(location, original) {
        const error = new this(`Unable to set visibility for file at location "${location}"`, 500, 'E_CANNOT_SET_VISIBILITY');
        error.location = location;
        error.original = original;
        return error;
    }
}
exports.CannotSetVisibilityException = CannotSetVisibilityException;
/**
 * Unable to generate url for a file. The assets serving is disabled
 */
class CannotGenerateUrlException extends utils_1.Exception {
    static invoke(location, diskName) {
        const error = new this(`Cannot generate URL for location "${location}". Make sure to set "serveFiles = true" for "${diskName}" disk`, 500, 'E_CANNOT_GENERATE_URL');
        error.location = location;
        return error;
    }
}
exports.CannotGenerateUrlException = CannotGenerateUrlException;
/**
 * Unable to list directory contents of given location
 */
class CannotListDirectoryException extends utils_1.Exception {
    static invoke(location, original) {
        const error = new this(`Cannot list directory contents of location "${location}"`, 500, 'E_CANNOT_LIST_DIRECTORY');
        error.location = location;
        error.original = original;
        return error;
    }
}
exports.CannotListDirectoryException = CannotListDirectoryException;
/**
 * Given location is trying to traverse beyond the root path
 */
class PathTraversalDetectedException extends utils_1.Exception {
    static invoke(location) {
        const error = new this(`Path traversal detected: "${location}"`, 500, 'E_PATH_TRAVERSAL_DETECTED');
        error.location = location;
        return error;
    }
}
exports.PathTraversalDetectedException = PathTraversalDetectedException;
