tethys.backend/providers/drive/exceptions/index.ts
Arno Kaimbacher 296c8fd46e - added own provider for drive methods
- renamed middleware Role and Can to role_middleware and can_middleware
- added some typing for inertia vue3 components
- npm updates
2024-04-23 19:36:45 +02:00

74 lines
2.2 KiB
TypeScript

// const utils_1 = require("@poppinss/utils");
// import * as utils_1 from "@poppinss/utils";
import { Exception } from '@poppinss/utils';
/**
* Custom exception for when a file cannot be deleted from a specified location
*/
export class CannotDeleteFileException extends Exception {
location: string;
original: any;
static invoke(location: string, original: any): CannotDeleteFileException {
const error = new this(`Cannot delete file at location "${location}"`, {
code: 'E_CANNOT_DELETE_FILE',
status: 500,
});
error.location = location;
error.original = original;
return error;
}
}
/**
* Custom exception for when file metadata cannot be retrieved
*/
export class CannotGetMetaDataException extends Exception {
location: string;
operation: string;
original: any;
static invoke(location: string, operation: string, original: any): CannotGetMetaDataException {
const error = new this(`Unable to retrieve the "${operation}" for file at location "${location}"`, {
code: 'E_CANNOT_GET_METADATA',
status: 500,
});
error.location = location;
error.operation = operation;
error.original = original;
return error;
}
}
/**
* Given location is trying to traverse beyond the root path
*/
export class PathTraversalDetectedException extends Exception {
location: string;
static invoke(location: string) {
const error = new this(`Path traversal detected: "${location}"`, {
code: 'E_PATH_TRAVERSAL_DETECTED',
status: 500,
});
error.location = location;
return error;
}
}
/**
* Unable to list directory contents of given location
*/
export class CannotListDirectoryException extends Exception {
location: string;
original: any;
static invoke(location: string, original: any): CannotListDirectoryException {
const error = new this(`Cannot list directory contents of location "${location}"`, {
status: 500,
code: 'E_CANNOT_LIST_DIRECTORY',
});
error.location = location;
error.original = original;
return error;
}
}