# Errors
The errors used in the Beacon communication are defined in the tzip-10 proposal.
If the wallet encounters an error while processing a request, the response will use the BeaconBaseMessage
described here and additionally add a BeaconErrorType
.
import { BeaconBaseMessage, BeaconErrorType, BeaconMessageType } from '../../..'
export interface ErrorResponse extends BeaconBaseMessage {
type: BeaconMessageType.Error
errorType: BeaconErrorType
errorData?: any
}
export enum BeaconErrorType {
BROADCAST_ERROR = 'BROADCAST_ERROR', // Broadcast | Operation Request: Will be returned if the user chooses that the transaction is broadcast but there is an error (eg. node not available).
NETWORK_NOT_SUPPORTED = 'NETWORK_NOT_SUPPORTED', // Permission: Will be returned if the selected network is not supported by the wallet / extension.
NO_ADDRESS_ERROR = 'NO_ADDRESS_ERROR', // Permission: Will be returned if there is no address present for the protocol / network requested.
NO_PRIVATE_KEY_FOUND_ERROR = 'NO_PRIVATE_KEY_FOUND_ERROR', // Sign: Will be returned if the private key matching the sourceAddress could not be found.
NOT_GRANTED_ERROR = 'NOT_GRANTED_ERROR', // Sign: Will be returned if the signature was blocked // (Not needed?) Permission: Will be returned if the permissions requested by the App were not granted.
PARAMETERS_INVALID_ERROR = 'PARAMETERS_INVALID_ERROR', // Operation Request: Will be returned if any of the parameters are invalid.
TOO_MANY_OPERATIONS = 'TOO_MANY_OPERATIONS', // Operation Request: Will be returned if too many operations were in the request and they were not able to fit into a single operation group.
TRANSACTION_INVALID_ERROR = 'TRANSACTION_INVALID_ERROR', // Broadcast: Will be returned if the transaction is not parsable or is rejected by the node.
SIGNATURE_TYPE_NOT_SUPPORTED = 'SIGNATURE_TYPE_NOT_SUPPORTED', // Sign: Will be returned if the signing type is not supported.
ABORTED_ERROR = 'ABORTED_ERROR', // Permission | Operation Request | Sign Request | Broadcast: Will be returned if the request was aborted by the user or the wallet.
UNKNOWN_ERROR = 'UNKNOWN_ERROR' // Used as a wildcard if an unexpected error occured.
}
# BroadcastBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class BroadcastBeaconError extends BeaconError {
public name: string = 'BroadcastBeaconError'
public title: string = 'Broadcast Error'
constructor() {
super(
BeaconErrorType.BROADCAST_ERROR,
'The transaction could not be broadcast to the network. Please try again.'
)
}
}
# NetworkNotSupportedBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class NetworkNotSupportedBeaconError extends BeaconError {
public name: string = 'NetworkNotSupportedBeaconError'
public title: string = 'Network Error'
constructor() {
super(
BeaconErrorType.NETWORK_NOT_SUPPORTED,
'The wallet does not support this network. Please select another one.'
)
}
}
# NoAddressBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class NoAddressBeaconError extends BeaconError {
public name: string = 'NoAddressBeaconError'
public title: string = 'No Address'
constructor() {
super(
BeaconErrorType.NO_ADDRESS_ERROR,
'The wallet does not have an account set up. Please make sure to set up your wallet and try again.'
)
}
}
# NoPrivateKeyBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class NoPrivateKeyBeaconError extends BeaconError {
public name: string = 'NoPrivateKeyBeaconError'
public title: string = 'Account Not Found'
constructor() {
super(
BeaconErrorType.NO_PRIVATE_KEY_FOUND_ERROR,
'The account you are trying to interact with is not available. Please make sure to add the account to your wallet and try again.'
)
}
}
# NotGrantedBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class NotGrantedBeaconError extends BeaconError {
public name: string = 'NotGrantedBeaconError'
public title: string = 'Permission Not Granted'
constructor() {
super(
BeaconErrorType.NOT_GRANTED_ERROR,
'You do not have the necessary permissions to perform this action. Please initiate another permission request and give the necessary permissions.'
)
}
}
# ParametersInvalidBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class ParametersInvalidBeaconError extends BeaconError {
public name: string = 'ParametersInvalidBeaconError'
public title: string = 'Parameters Invalid'
constructor() {
super(
BeaconErrorType.PARAMETERS_INVALID_ERROR,
'Some of the parameters you provided are invalid and the request could not be completed. Please check your inputs and try again.'
)
}
}
# TooManyOperationsBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class TooManyOperationsBeaconError extends BeaconError {
public name: string = 'TooManyOperationsBeaconError'
public title: string = 'Too Many Operations'
constructor() {
super(
BeaconErrorType.TOO_MANY_OPERATIONS,
'The request contains too many transactions. Please include fewer operations and try again.'
)
}
}
# TransactionInvalidBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class TransactionInvalidBeaconError extends BeaconError {
public name: string = 'TransactionInvalidBeaconError'
public title: string = 'Transaction Invalid'
public get fullDescription(): string {
return `${this.description}<br /><pre style="text-align: left">${JSON.stringify(
this.data,
undefined,
2
)}</pre>`
}
constructor(public readonly data: any) {
super(
BeaconErrorType.TRANSACTION_INVALID_ERROR,
`The transaction is invalid and the node did not accept it.`
)
this.data = data
}
}
# UnknownBeaconError
import { BeaconError, BeaconErrorType } from '..'
export class UnknownBeaconError extends BeaconError {
public name: string = 'UnknownBeaconError'
public title: string = 'Error'
constructor() {
super(
BeaconErrorType.UNKNOWN_ERROR,
'An unknown error occured. Please try again or report it to a developer.'
)
}
}