PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/src/core
Просмотр файла: common.ts
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
/**
* This error is used to explain why parsing failed.
*/
export class ParsingError<T> extends Error {
/**
* This provides a programmatic way to access why parsing failed. Downstream devs
* might want to use this to build their own error messages if the default error
* messages are not suitable for their use case. This should be an enum.
*/
public invalidReason: T;
/**
* Creates an instance of the error with a specified message and invalid reason.
*
* @param message The error message that describes the issue.
* @param invalidReason The reason why the input is considered invalid.
*/
constructor(message: string, invalidReason: T) {
super(message);
this.invalidReason = invalidReason;
}
}
/**
* Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,
* this type is returned from "defensive" functions like isValid.
*/
export type ParsingResult<T> = {
/**
* True if valid, false otherwise.
*/
valid: boolean;
/**
* If valid is false, this will be a code explaining why parsing failed.
*/
invalidReason?: T;
/**
* If valid is false, this will be a string explaining why parsing failed.
*/
invalidReasonMessage?: string;
};
Выполнить команду
Для локальной разработки. Не используйте в интернете!