# Error Code and Error Handling
# Error handling
The gateway error code usually starts with102, indicating a Weixin Mini Program gateway error.Other error codes start with-601, indicating a system error.
In the case of automatic access, after a gateway error, a downgrade retry is automatically performed usingwx.request.At this point, the developer does not need to deal with gateway errors, but simply focuses on source site errors.
In the case of automatic access downgrading / manual access, developers can handle errors infailcallback orcatchwith the following code.
// Automatic Access
wx.request({
url: '...',
fail: (error) => {
if (error.errCode) {
// 处理网关错误(如果关闭了自动降级功能)
console.error('网关错误码:', error.errCode); // 网关错误码: 102020
console.error('错误信息:', error.message); // 错误信息: gateway.call: fail wx system error , code: 102020, callid: 1755674590892-H_i-6vCT
} else {
// 处理降级到源站后的其他网络错误
console.error('其他错误:', error);
}
}
})
// Manual Access
gateway.call({
url: '...',
fail: (error) => {
if (error.errCode) {
// 处理网关错误
console.error('网关错误码:', error.errCode); // 网关错误码: 102020
console.error('错误信息:', error.message); // 错误信息: gateway.call: fail wx system error , code: 102020, callid: 1755674590892-H_i-6vCT
} else {
// 处理其他错误
console.error('其他错误:', error);
}
}
})
# Error code
| errCode | Introductions |
|---|---|
| 102003 | Trigger user frequency limit |
| 102006 | Illegal Requests |
| 102016 | A routing error.The request address is not in WeChat gateway's Weixin Mini Program URL |
| 102020 | Trigger WeChat Gateway Package QPS Limit |
| 102021 | Trigger WeChat Gateway Package Bandwidth Limit |
| 102022 | The request address is not in WeChat gateway's Weixin Mini Program URL, or the local gateway configuration version is low |
| 104100 | Request a replay of the interception |
| -601001 | The system failed |
| -601008 | Request timeout |
| -601069 | WeChat Connection failed while gateway accesses source station |