@helia/verified-fetch
Version:
A fetch-like API for obtaining verified & trustless IPFS content on the web
33 lines • 1.11 kB
JavaScript
/**
* If a plugin encounters an error, it should throw an instance of this class.
*/
export class PluginError extends Error {
name = 'PluginError';
code;
fatal;
details;
response;
constructor(code, message, options) {
super(message);
this.code = code;
this.fatal = options?.fatal ?? false;
this.details = options?.details;
this.response = options?.response;
}
}
/**
* If a plugin encounters a fatal error and verified-fetch should not continue processing the request, it should throw
* an instance of this class.
*
* Note that you should be very careful when throwing a `PluginFatalError`, as it will stop the request from being
* processed further. If you do not have a response to return to the client, you should consider throwing a
* `PluginError` instead.
*/
export class PluginFatalError extends PluginError {
name = 'PluginFatalError';
constructor(code, message, options) {
super(code, message, { ...options, fatal: true });
this.name = 'PluginFatalError';
}
}
//# sourceMappingURL=errors.js.map