Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 1x 1x 23x 23x 23x 23x 1x 4x 4x 5x 5x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x | /* @flow */
export const ERROR_CODES = {
MISSING_PARAMETER: 'missing_parameter',
REMOTE_SERVICE_ERROR: 'remote_service_error',
INVALID_STATE: 'invalid_state',
NO_SESSION_DATA: 'no_session_data',
UNKNOWN: 'unknown'
}
Object.freeze(ERROR_CODES)
type ErrorType = {
code: string,
parameter?: string,
message: string
}
export class BlockstackError extends Error {
message: string
code: string
parameter: ?string
constructor(error: ErrorType) {
super(error.message)
this.message = error.message
this.code = error.code
this.parameter = error.parameter ? error.parameter : null
}
toString() {
return `${super.toString()}
code: ${this.code} param: ${this.parameter ? this.parameter : 'n/a'}`
}
}
export class InvalidParameterError extends BlockstackError {
constructor(parameter: string, message: string = '') {
super({ code: 'missing_parameter', message, parameter: '' })
this.name = 'MissingParametersError'
}
}
export class MissingParameterError extends BlockstackError {
constructor(parameter: string, message: string = '') {
super({ code: ERROR_CODES.MISSING_PARAMETER, message, parameter })
this.name = 'MissingParametersError'
}
}
export class RemoteServiceError extends BlockstackError {
response: Response
constructor(response: Response, message: string = '') {
super({ code: ERROR_CODES.REMOTE_SERVICE_ERROR, message })
this.response = response
}
}
export class InvalidDIDError extends BlockstackError {
constructor(message: string = '') {
super({ code: 'invalid_did_error', message })
this.name = 'InvalidDIDError'
}
}
export class NotEnoughFundsError extends BlockstackError {
leftToFund: number
constructor(leftToFund: number) {
const message = `Not enough UTXOs to fund. Left to fund: ${leftToFund}`
super({ code: 'not_enough_error', message })
this.leftToFund = leftToFund
this.name = 'NotEnoughFundsError'
this.message = message
}
}
export class InvalidAmountError extends BlockstackError {
fees: number
specifiedAmount: number
constructor(fees: number, specifiedAmount: number) {
const message = `Not enough coin to fund fees transaction fees. Fees would be ${fees},`
+ ` specified spend is ${specifiedAmount}`
super({ code: 'invalid_amount_error', message })
this.specifiedAmount = specifiedAmount
this.fees = fees
this.name = 'InvalidAmountError'
this.message = message
}
}
export class LoginFailedError extends BlockstackError {
constructor(reason: string) {
const message = `Failed to login: ${reason}`
super({ code: 'login_failed', message })
this.message = message
this.name = 'LoginFailedError'
}
}
export class SignatureVerificationError extends BlockstackError {
constructor(reason: string) {
const message = `Failed to verify signature: ${reason}`
super({ code: 'signature_verification_failure', message })
this.message = message
this.name = 'SignatureVerificationError'
}
}
export class InvalidStateError extends BlockstackError {
constructor(message: string) {
super({ code: ERROR_CODES.INVALID_STATE, message })
this.message = message
this.name = 'InvalidStateError'
}
}
export class NoSessionDataError extends BlockstackError {
constructor(message: string) {
super({ code: ERROR_CODES.INVALID_STATE, message })
this.message = message
this.name = 'NoSessionDataError'
}
}
|