zoukankan      html  css  js  c++  java
  • 常见错误码及定义

    常见错误码及定义

    1. 错误码暂定都是5位数字,并配有相应的英文解释
    2. 错误码为 0 表示成功,其他都表示错误
    3. 错误码按模块按功能场景分级分段,前三位错误码表示模块,第四位表示模块下的功能。举例,商城系统里有交易模块和商品模块,则可以这样划分:401开头的表示交易模块,402开头的表示商品模块,4011开头的表示交易模块里的下单场景需要用到的错误码,4021表示商品模块下的添加商品场景里需要用到的错误码。如果某个场景功能下需要的比较多的错误码,则可以使用其他未被使用的码段,即该场景功能可以拥有多个码段,然后通过添加注释等方式让人理解即可。
    4. 数字 1 开头的错误码表示系统级别的错误,比如缺少某种字符集,连不上数据库之类的,系统级的错误码不需要分模块,可以按照自增方式进行添加
    5. 数字 4 开头的错误码表示API参数校验失败,比如 交易模块下单场景中,订单金额参数不能为空 可以用 40111 错误码来表示
    6. 数字 5 开头的错误码表示后台业务校验失败,比如 交易模块下单场景中,该用户没有下单权限可以用 50111 错误码来表示
    7. 数字 4 开头的错误码与数字 5 开头的错误码对应的模块分类需要保持一致,即 4011 表示交易模块下单场景的API错误,5011 表示交易模块下单场景的业务错误
    8. 错误码按需分配,逐步增加,灵活扩展

    网上确实没有比较成熟或者通用的设计方法,只能参考目前几大互联网巨头们的设计方法,然后结合实际需求设计出符合自己公司的解决方案。

    把我目前设计的错误码方案分享给大家:
    统一格式:A-BB-CCC
    A:错误级别,如1代表系统级错误,2代表服务级错误;
    B:项目或模块名称,一般公司不会超过99个项目;
    C:具体错误编号,自增即可,一个项目999种错误应该够用;

    参考:
    淘宝开放平台
    公共返回码说明
    Error code - 微博API
    http://my.oschina.net/foxty/blog/382344

     

    一、授权/令牌请求接口返回码

    描述应用发起授权请求或令牌请求时,开放平台的返回码。

    错误码

    错误描述

    Error Description

    10000

    非法的请求参数

    Invalid request

    10001

    用户认证失败

    Invalid client

    10002

    非法的授权信息

    Invalid grant

    10003

    应用没有被授权,无法使用所指定的grant_type

    Unauthorized client

    10004

    grant_type字段超过定义范围

    Unsupported grant_type

    10005

    scope信息无效或超出范围

    Invalid scope

    10006

    提供的更新令牌已过期

    Expired token

    10007

    redirect_uri字段与注册应用时所填写的不匹配

    Redirect_uri mismatch

    10008

    response_type参数值超过定义范围

    Unsupported response type

    10009

    用户或授权服务器拒绝授予数据访问权限

    Access denied

    二、API通用返回码

    描述API接口的共性返回码,API自定义的接口返回码请参阅对应API接口文档描述。

    错误码

    错误描述

    Error Description

    0

    成功

    Success

    1

    未知错误

    Unknown error

    2

    服务暂不可用

    Service temporarily unavailable

    3

    未知的方法

    Unsupported openapi method

    4

    接口调用次数已达到设定的上限

    Open api request limit reached

    5

    请求来自未经授权的IP地址

    Unauthorized client IP address

    6

    无权限访问该用户数据

    No permission to access user data

    7

    来自该refer的请求无访问权限

    No permission to access data for this referer

    100

    请求参数无效

    Invalid parameter

    101

    api key无效

    Invalid API key

    104

    无效签名

    Incorrect signature

    105

    请求参数过多

    Too many parameters

    106

    未知的签名方法

    Unsupported signature method

    107

    timestamp参数无效

    Invalid/Used timestamp parameter

    109

    无效的用户资料字段名

    Invalid user info field

    110

    无效的access token

    Access token invalid or no longer valid

    111

    access token过期

    Access token expired

    210

    用户不可见

    User not visible

    211

    获取未授权的字段

    Unsupported permission

    212

    没有权限获取用户的email

    No permission to access user email

    800

    未知的存储操作错误

    Unknown data store API error

    801

    无效的操作方法

    Invalid operation

    802

    数据存储空间已超过设定的上限

    Data store allowable quota was exceeded

    803

    指定的对象不存在

    Specified object cannot be found

    804

    指定的对象已存在

    Specified object already exists

    805

    数据库操作出错,请重试

    A database error occurred. Please try again

    900

    访问的应用不存在

    No such application exists

    转载:http://open.189.cn/index.php?m=content&c=index&a=lists&catid=31

    百度Open API错误码定义

    Error Code Error Description(Chinese) Error Description(English)
    0 成功 Success
    1 未知错误 Unknown error
    2 服务暂不可用 Service temporarily unavailable
    3 未知的方法 Unsupported openapi method
    4 接口调用次数已达到设定的上限 Open api request limit reached
    5 请求来自未经授权的IP地址 Unauthorized client IP address:%s
    6 无权限访问该用户数据 No permission to access data
    7 来自该refer的请求无访问权限 No permission to access data for this referer
    100 请求参数无效 Invalid parameter
    101 api key无效 Invalid API key
    102 session key无效 Session key invalid or no longer valid
    103 call_id参数无效 Invalid/Used call_id parameter
    104 无效签名 Incorrect signature
    105 请求参数过多 Too many parameters
    106 未知的签名方法 Unsupported signature method
    107 timestamp参数无效 Invalid/Used timestamp parameter
    108 无效的user id Invalid user id
    109 无效的用户资料字段名 Invalid user info field
    110 无效的access token Access token invalid or no longer valid
    111 access token过期 Access token expired
    112 session key过期 Session key expired
    114 无效的ip参数 Invalid Ip
    210 用户不可见 User not visible
    211 获取未授权的字段 Unsupported permission
    212 没有权限获取用户的email No permission to access user email
    800 未知的存储操作错误 Unknown data store API error
    801 无效的操作方法 Invalid operation
    802 数据存储空间已超过设定的上限 Data store allowable quota was exceeded
    803 指定的对象不存在 Specified object cannot be found
    804 指定的对象已存在 Specified object already exists
    805 数据库操作出错,请重试 A database error occurred. Please try again
    900 访问的应用不存在 No such application exists
    950 批量操作已开始,请先调用end_batch接口结束前一个批量操作 begin_batch already called, please make sure to call end_batch first
    951 结束批量操作的接口调用不应该在start_batch接口之前被调用 end_batch called before start_batch
    952 每个批量调用不能包含多于20个接口调用 Each batch API can not contain more than 20 items
    953 该接口不适合在批量调用操作中被使用 Method is not allowed in batch mode
  • 相关阅读:
    Python获取Linux的家目录
    Python 批量安装包、查看当前程序依赖的包
    获取linux目录下最新的文件
    Linux破解navicat
    Linux添加PATH
    Linux下文件分析 | 命令行
    ROP | 蒸米 -x86
    Jarvis OJ | guess
    杂项入门
    Whale ctf | misc
  • 原文地址:https://www.cnblogs.com/xiang--liu/p/9710106.html
Copyright © 2011-2022 走看看