Documentation Index
Fetch the complete documentation index at: https://developers-sandbox.uqpaytech.com/llms.txt
Use this file to discover all available pages before exploring further.
错误类型
所有 API 错误都会抛出继承自 UQPayError 的带类型错误类:
import {
AuthenticationError,
ValidationError,
NotFoundError,
RateLimitError,
ServerError,
NetworkError,
SimulatorNotAvailableError,
} from '@uqpay/sdk'
每个错误对象暴露以下字段:
| 字段 | 类型 | 说明 |
|---|
message | string | 可读的错误描述 |
httpStatus | number | HTTP 状态码 |
type | string | API 错误类型标识 |
code | string | API 错误码 |
捕获错误
try {
const account = await client.account.accounts.retrieve('acc-123')
} catch (err) {
if (err instanceof NotFoundError) {
console.log('账户未找到')
} else if (err instanceof ValidationError) {
console.log('请求参数错误:', err.message)
} else if (err instanceof RateLimitError) {
console.log('触发限流,SDK 会自动重试')
} else if (err instanceof NetworkError) {
console.log('网络错误:', err.message)
} else if (err instanceof SimulatorNotAvailableError) {
console.log('模拟器仅在沙盒可用')
}
}
SDK 会对服务端错误、限流和网络错误按指数退避自动重试。
全局或单次配置重试:
// 全局——创建 client 时设置
const client = new UQPayClient({
// ...
maxRetries: 3,
})
// 单次请求——覆盖全局设置
await client.account.accounts.retrieve('acc-123', { maxRetries: 0 })