secret-polar
Version:
Polar is a development environment to compile, deploy, test, run scrt contracts on different networks.
60 lines (59 loc) • 2.48 kB
TypeScript
import { ErrorDescriptor } from './errors-list';
export declare class PolarError extends Error {
static isPolarError(other: any): other is PolarError;
static isPolarErrorType(other: any, // eslint-disable-line
descriptor: ErrorDescriptor): other is PolarError;
readonly errorDescriptor: ErrorDescriptor;
readonly number: number;
readonly messageArguments: Record<string, any>;
readonly parent?: Error;
private readonly _isPolarError;
constructor(errorDescriptor: ErrorDescriptor, messageArguments?: Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any
parentError?: Error);
}
/**
* This class is used to throw errors from polar plugins made by third parties.
*/
export declare class PolarPluginError extends Error {
static isPolarPluginError(other: any): other is PolarPluginError;
readonly parent?: Error;
readonly pluginName: string;
private readonly _isPolarPluginError;
/**
* Creates a PolarPluginError.
*
* @param pluginName The name of the plugin.
* @param message An error message that will be shown to the user.
* @param parent The error that causes this error to be thrown.
*/
constructor(pluginName: string, message: string, parent?: Error);
/**
* A DEPRECATED constructor that automatically obtains the caller package and
* use it as plugin name.
*
* @deprecated Use the above constructor.
*
* @param message An error message that will be shown to the user.
* @param parent The error that causes this error to be thrown.
*/
constructor(message: string, parent?: Error);
}
/**
* This function applies error messages templates like this:
*
* - Template is a string which contains a variable tags. A variable tag is a
* a variable name surrounded by %. Eg: %plugin1%
* - A variable name is a string of alphanumeric ascii characters.
* - Every variable tag is replaced by its value.
* - %% is replaced by %.
* - Values can't contain variable tags.
* - If a variable is not present in the template, but present in the values
* object, an error is thrown.
*
* @param template The template string.
* @param values A map of variable names to their values.
*/
export declare function applyErrorMessageTemplate(template: string, values: {
[templateVar: string]: any;
}): string;
export declare function assertPolarInvariant(invariant: boolean, message: string): asserts invariant;