UNPKG

@adonisjs/drive

Version:

A thin wrapper on top of Flydrive to work seamlessly with AdonisJS

57 lines (56 loc) 1.64 kB
import { type HttpContext } from '@adonisjs/core/http'; import { Exception } from '@adonisjs/core/exceptions'; /** * The exception is raised by the local file server when * trying to serve a file during an HTTP request. * * @example * ```js * try { * await drive.serve('file.txt') * } catch (error) { * if (error instanceof CannotServeFileException) { * console.log('Cannot serve file:', error.message) * } * } * ``` */ export declare class CannotServeFileException extends Exception { #private; /** * Flag to determine if debug information should be shown. * Set to false in production mode. */ debug: boolean; /** * Creates a new CannotServeFileException instance. * * @param originalError - The original error that caused the file serving to fail */ constructor(originalError: any); /** * Parses the original error to find the accurate error * message, stack and the status code. * * @param error - The CannotServeFileException instance to parse */ parseError(error: this): { stack: any; status: number; message: any; }; /** * Converts error to an HTTP response. * * @param error - The CannotServeFileException instance to handle * @param ctx - The HTTP context for the request */ handle(error: this, ctx: HttpContext): void; /** * Reporting the error using the logger * * @param error - The CannotServeFileException instance to report * @param ctx - The HTTP context for logging */ report(error: this, ctx: HttpContext): void; }