官术网_书友最值得收藏!

Returning errors

In the instance of failure, users of your API should be able to write one piece of code that handles errors across different endpoints. A standard error entity will help your consumers by enabling them to write DRY code whenever an error caused by client or server occurs.

The Microsoft API guidelines recommend the following format for these entities:

{ 
"error": {
"code": "BadArgument",
"message": "Previous passwords may not be reused",
"target": "password",
"innererror": a {
"code": "PasswordError",
"innererror": {
"code": "PasswordDoesNotMeetPolicy",
"minLength": "6",
"maxLength": "64",
"characterTypes": ["lowerCase","upperCase","number","symbol"],
"minDistinctCharacterTypes": "2",
"innererror": {
"code": "PasswordReuseNotAllowed"
}
}
}
}
}

ErrorResponse: Object

The ErrorResponse is the top level object which will be returned by our response and contains the following fields:

 

Error: Object

The Error object is the detail for our error response; it provides full detail for the reason that the error occurred:

InnerError: Object

 

Microsoft has provided an excellent API guidelines resource, you can read more about returning errors by looking at the following link:

https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#51-errors

主站蜘蛛池模板: 肇州县| 南汇区| 武义县| 雷州市| 舞阳县| 将乐县| 灯塔市| 枣强县| 台东县| 景德镇市| 潍坊市| 遂平县| 山阴县| 营山县| 肃宁县| 宝兴县| 共和县| 大田县| 泰顺县| 富宁县| 丰台区| 湘潭县| 石屏县| 德钦县| 东莞市| 独山县| 蕉岭县| 贵定县| 新野县| 株洲县| 楚雄市| 蓬安县| 兖州市| 酒泉市| 银川市| 武陟县| 夏邑县| 吉林市| 汾阳市| 长岭县| 肥乡县|