UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

79 lines 2.84 kB
import { CustomError } from "../customError"; import { matchRellErrorString } from "../formatter"; export class MissingPubKeyError extends CustomError { constructor() { super(`No public key was provided`, 400); } } export class MissingBlockchainIdentifierError extends CustomError { constructor() { super(`No blockchain identifier was provided. Include either a blockchainRid (string) or a blockchainIid (number).`, 400); } } export class MissingNodeUrlError extends CustomError { constructor() { super(`No node url or directory node url was provided. Include either a nodeUrl (string or string[]) or a directory node url (string or string[]).`, 400); } } export class BlockchainUrlUndefinedException extends CustomError { constructor(brid) { const idType = typeof brid === "string" ? "BRID" : "IID"; super(`Cannot find nodes hosting the blockchain with ${idType} ${brid}`, 400); } } export class DirectoryNodeUrlPoolException extends CustomError { constructor() { super(`No directory node url was provided`, 400); } } export class InvalidTransactionFormatException extends CustomError { constructor() { super(`The transaction is not in the right format`, 400); } } export class GetTransactionRidException extends CustomError { constructor(error) { super(`"Error occurred while getting transaction RID:", ${error}`, 400); } } export class TxRejectedError extends Error { constructor(rejectReason) { super(`Transaction was rejected, ${rejectReason}`); this.name = "TxRejectedError"; this.fullReason = rejectReason; const result = matchRellErrorString(rejectReason); this.shortReason = result.shortReason; this.rellLine = result.rellLine; this.operation = result.operation; } } export class UnexpectedStatusError extends CustomError { constructor(status, error) { let errorMessage = `Unexpected status code from server. Code: ${status}.`; if (status === null) { super(errorMessage, 500); // default status code } else { if (error) { errorMessage += ` Message: ${error}.`; } super(errorMessage, status); } } } export class InvalidTxRidException extends CustomError { constructor(txRID) { super(`expected length 32 of txRID, but got ${txRID && txRID.length}`, 400); } } export class SerializedTransactionFormatException extends CustomError { constructor() { super(`messageHash is not a Buffer`, 400); } } export class GetBridFromChainException extends Error { constructor(chainId, reason) { super(`Error resolving BRID for chainId ${chainId}, reason: ${reason}`); } } //# sourceMappingURL=errors.js.map