本页列出可以通过try...catcyh捕获的远程服务错误。
除authorze()方法外,所有的方法都需要验证权限。验证权限失败时返回错误401 Unauthorized。每个方法的错误中不再重复说明。用户的 KYC 状态不正确时也属于
401 Unauthorized。await (async () => { try{ await $legend.getTradingPairs() } catch(e) { console.log(e.response.status) // 401 console.log(e.response.data) // { "message": "Unauthenticated." } } })()
authorize()
await (async () => {
try{
await $legend.authorize()
} catch(e) {
console.log(e.response.data)
// {
// "success": "false",
// "code" :"101100",
// "message":"Due to compliance reasons, we are unable to offer services to users from this region.",
// "metadata": {
// "ip": "1.1.1.1",
// "country":"AF"
// }
// }
}
})()await (async () => {
try{
await $legend.authorize()
} catch(e) {
console.log(e.response.data)
// {
// "message": "Unauthenticated",
// "errors": {
// "signature": "Unauthenticated"
// }
// }
}
})()await (async () => {
try{
await $legend.authorize()
} catch(e) {
console.log(e.response.data)
// {
// "message": "Timestamp is not valid.",
// "errors": {
// "timestamp": "Timestamp is not valid."
// }
// }
}
})()getTradingPairs()
await (async () => {
try{
await $legend.getTradingPairs()
} catch(e) {
console.log(e.response.data)
// { "message": "Unauthenticated." }
}
})()getCurrencies()
getBalance()
getRegions()
await (async () => {
try{
await $legend.getRegions()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The parent id field is required.",
// "errors": {
// "parent_id": [
// "The parent id field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.getRegions()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The selected residential is invalid.",
// "errors": {
// "residential": [
// "The selected residential is invalid."
// ]
// }
// }
}
})()getBillingAddress()
setBillingAddress()
await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The city is not allowed.",
// "errors": {
// "city": [
// "The city is not allowed."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The country field is required when country iso2 code is not present.",
// "errors": {
// "country": [
// "The country field is required when country iso2 code is not present."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The country iso2 code must be 2 characters.",
// "errors": {
// "country_iso2_code": [
// "The country iso2 code must be 2 characters."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The address line 1 field is required.",
// "errors": {
// "address_line_1": [
// "The address line 1 field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The state field is required.",
// "errors": {
// "state": [
// "The state field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The state is invalid.",
// "errors": {
// "state": [
// "The state is invalid."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The city field is required.",
// "errors": {
// "city": [
// "The city field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The selected city is invalid.",
// "errors": {
// "city": [
// "The selected city is invalid."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The zipcode field is required.",
// "errors": {
// "zipcode": [
// "The zipcode field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The country field is required when country iso2 code is not present.",
// "errors": {
// "country": [
// "The country field is required when country iso2 code is not present."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.setBillingAddress()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The country iso2 code must be 2 characters.",
// "errors": {
// "country_iso2_code": [
// "The country iso2 code must be 2 characters."
// ]
// }
// }
}
})()getAllPaymentMethods()
getPaymentMethodsByTrade()
addPaymentMethod()
222await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The data field is required.",
// "errors": {
// "data": [
// "The data field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The data.token field is required.",
// "errors": {
// "data.token": [
// "The data.token field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The currency field is required.",
// "errors": {
// "currency": [
// "The currency field is required."
// ]
// }
// }
}
})() 22 await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The billing address field is required.",
// "errors": {
// "billing_address": [
// "You are not the owner of this model."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The selected billing address is invalid.",
// "errors": {
// "billing_address": [
// "The selected billing address is invalid."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The selected billing address is invalid.",
// "errors": {
// "billing_address": [
// "You are not the owner of this model."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "failed",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card.",
// "message": "There’s an issue with your card. Please try another one."
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "failed",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card.",
// "message": "Please call the customer support of your issuing bank to make sure the transaction wasn’t incorrectly flagged as fraudulent, or try a different card."
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "failed",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card due to the failure of 3D-Secure authentication.",
// "message": "Please double check the card number and details entered."
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "failed",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card as it was declined by your issuing bank.",
// "message": "Please try a different card. Debit cards have higher success rates than credit cards."
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "failed",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card due to insufficient funds or credits.",
// "message": "Please try a different card."
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "failed",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Duplicated card",
// "message": "You’ve added this card previously. Continue your journey by adding a different card!"
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "error",
// "data": {
// "target": "checkout-redirect",
// "status": "error",
// "subject": "Unable to verify your card.",
// "message": "There’s an issue with your card. Please try another one."
// }
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "error",
// "data": "Card form invalid"
// }
}
})()await (async () => {
try{
await $legend.addPaymentMethod()
} catch(e) {
console.log(e)
// {
// "status": "pending",
// "data": {
// "target": "checkout-redirect",
// "status": "pending"
// }
// }
}
})()removePaymentMethod()
await (async () => {
try{
await $legend.removePaymentMethod()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The payment method id field is required.",
// "errors": {
// "payment_method_id": [
// "The payment method id field is required."
// ]
// }
// }
}
})()quoteByFiat()
await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The side field is required.",
// "errors": {
// "side": [
// "The side field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The selected side is invalid.",
// "errors": {
// "side": [
// "The selected side is invalid."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The pair field is required.",
// "errors": {
// "pair": [
// "The pair field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The selected pair is invalid.",
// "errors": {
// "pair": [
// "The selected pair is invalid."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The size field is required.",
// "errors": {
// "size": [
// "The size field is required."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The size must be a number.",
// "errors": {
// "size": [
// "The size must be a number."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The size is too small for exchange.",
// "errors": {
// "size": [
// "The size is too small for exchange."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The size cannot be negative.",
// "errors": {
// "size": [
// "The size cannot be negative."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The size exceeds trade limit.",
// "errors": {
// "size": [
// "The size exceeds trade limit."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.quoteByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The selected type is invalid.",
// "errors": {
// "type": [
// "The selected type is invalid."
// ]
// }
// }
// type 可以是 'balance', 'ach', 'ach_balance', 'credit_card'
}
})()orderByFiat()
await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "To complete the verification process for your account, please check your email. We have sent instructions on how to finalize the verification of your latest deposits/withdrawals.",
// "error_code": "RFI_REQUIRED",
// "errors": {
// "rfi": [
// "RFI required"
// ]
// },
// "data": {
// "url": "",
// "email": "",
// "grace_period_end_timestamp": null
// }
// }
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "To complete the verification process for your account, please check your email. We have sent instructions on how to finalize the verification of your latest deposits/withdrawals.",
// "error_code": "EDD_REQUIRED",
// "errors": {
// "edd": [
// "EDD required"
// ]
// },
// "data": {
// "email": ""
// }
// }
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "side": [
// "The selected side is invalid."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "pair": [
// "The selected pair is invalid."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "size": [
// "The size field is required."
// ]
// }
// }
}
})()
await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "size": [
// "The size must be a number."
// ]
// }
// }
}
})()
await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "size": [
// "The size must be greater than minimum size for exchange."
// ]
// }
// }
}
})()
await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "size": [
// "The size cannot be negative."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "size": [
// "The size exceeds trade limit."
// ]
// }
// }
}
})()
await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "The given data was invalid.",
// "errors": {
// "type": [
// "The selected type is invalid."
// ]
// }
// }
//
// type 可以是 'balance', 'ach', 'ach_balance', 'credit_card'
}
})()
await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "Card rejected.",
// "error_code": "card_rejected",
// "errors": {
// "trade": [
// "Card rejected."
// ]
// }
// }
// 具体的错误原因需要联系服务端查询
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "code": "422",
// "message": "Amount exceeds remaining daily limits.",
// "errors": {
// "trade": [
// "Amount exceeds remaining daily limits."
// ]
// }
// }
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e.response.data)
// {
// "message": "Account suspended - Please contact [email protected]",
// "error": "Account suspended - Please contact [email protected]"
// }
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "failed",
// "error_code": "failed_to_trade",
// "subject": "Payment failed",
// "message": "We’re sorry but card payment failed. Please try again.",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "error_code": "failed_to_trade",
// "subject": "Payment failed",
// "message": "We’re sorry but card payment failed. Please try again."
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card.",
// "message": "There’s an issue with your card. Please try another one.",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card.",
// "message": "There’s an issue with your card. Please try another one.",
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card.",
// "message": "Please call the customer support of your issuing bank to make sure the transaction wasn’t incorrectly flagged as fraudulent, or try a different card.",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card.",
// "message": "Please call the customer support of your issuing bank to make sure the transaction wasn’t incorrectly flagged as fraudulent, or try a different card."
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card due to the failure of 3D-Secure authentication.",
// "message": "Please double check the card number and details entered.",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card due to the failure of 3D-Secure authentication.",
// "message": "Please double check the card number and details entered."
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card as it was declined by your issuing bank.",
// "message": "Please try a different card. Debit cards have higher success rates than credit cards."
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card as it was declined by your issuing bank.",
// "message": "Please try a different card. Debit cards have higher success rates than credit cards."
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card due to insufficient funds or credits.",
// "message": "Please try a different card.",
// "data": {
// "target": "checkout-redirect",
// "status": "failed",
// "subject": "Unable to verify your card due to insufficient funds or credits.",
// "message": "Please try a different card."
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "error",
// "subject": "Unable to verify your card.",
// "message": "There’s an issue with your card. Please try another one.",
// "data": {
// "target": "checkout-redirect",
// "status": "error",
// "subject": "Unable to verify your card.",
// "message": "There’s an issue with your card. Please try another one."
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()await (async () => {
try{
await $legend.orderByFiat()
} catch(e) {
console.log(e)
// {
// "target": "checkout-redirect",
// "status": "pending",
// "data": {
// "target": "checkout-redirect",
// "status": "pending"
// }
// }
// 数据结构里的冗余内容是为了保持向后兼容
}
})()

