Skip to content

Commit 6fd2069

Browse files
authored
fix(error): Add human readable titles for error code variants (#367)
1 parent 9be55e9 commit 6fd2069

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

schema/schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,42 +978,49 @@
978978
"const": -32700,
979979
"description": "**Parse error**: Invalid JSON was received by the server.\nAn error occurred on the server while parsing the JSON text.",
980980
"format": "int32",
981+
"title": "Parse error",
981982
"type": "integer"
982983
},
983984
{
984985
"const": -32600,
985986
"description": "**Invalid request**: The JSON sent is not a valid Request object.",
986987
"format": "int32",
988+
"title": "Invalid request",
987989
"type": "integer"
988990
},
989991
{
990992
"const": -32601,
991993
"description": "**Method not found**: The method does not exist or is not available.",
992994
"format": "int32",
995+
"title": "Method not found",
993996
"type": "integer"
994997
},
995998
{
996999
"const": -32602,
9971000
"description": "**Invalid params**: Invalid method parameter(s).",
9981001
"format": "int32",
1002+
"title": "Invalid params",
9991003
"type": "integer"
10001004
},
10011005
{
10021006
"const": -32603,
10031007
"description": "**Internal error**: Internal JSON-RPC error.\nReserved for implementation-defined server errors.",
10041008
"format": "int32",
1009+
"title": "Internal error",
10051010
"type": "integer"
10061011
},
10071012
{
10081013
"const": -32000,
10091014
"description": "**Authentication required**: Authentication is required before this operation can be performed.",
10101015
"format": "int32",
1016+
"title": "Authentication required",
10111017
"type": "integer"
10121018
},
10131019
{
10141020
"const": -32002,
10151021
"description": "**Resource not found**: A given resource, such as a file, was not found.",
10161022
"format": "int32",
1023+
"title": "Resource not found",
10171024
"type": "integer"
10181025
},
10191026
{

schema/schema.unstable.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,48 +1074,56 @@
10741074
"const": -32700,
10751075
"description": "**Parse error**: Invalid JSON was received by the server.\nAn error occurred on the server while parsing the JSON text.",
10761076
"format": "int32",
1077+
"title": "Parse error",
10771078
"type": "integer"
10781079
},
10791080
{
10801081
"const": -32600,
10811082
"description": "**Invalid request**: The JSON sent is not a valid Request object.",
10821083
"format": "int32",
1084+
"title": "Invalid request",
10831085
"type": "integer"
10841086
},
10851087
{
10861088
"const": -32601,
10871089
"description": "**Method not found**: The method does not exist or is not available.",
10881090
"format": "int32",
1091+
"title": "Method not found",
10891092
"type": "integer"
10901093
},
10911094
{
10921095
"const": -32602,
10931096
"description": "**Invalid params**: Invalid method parameter(s).",
10941097
"format": "int32",
1098+
"title": "Invalid params",
10951099
"type": "integer"
10961100
},
10971101
{
10981102
"const": -32603,
10991103
"description": "**Internal error**: Internal JSON-RPC error.\nReserved for implementation-defined server errors.",
11001104
"format": "int32",
1105+
"title": "Internal error",
11011106
"type": "integer"
11021107
},
11031108
{
11041109
"const": -32800,
11051110
"description": "**Request cancelled**: **UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nExecution of the method was aborted either due to a cancellation request from the caller or\nbecause of resource constraints or shutdown.",
11061111
"format": "int32",
1112+
"title": "Request cancelled",
11071113
"type": "integer"
11081114
},
11091115
{
11101116
"const": -32000,
11111117
"description": "**Authentication required**: Authentication is required before this operation can be performed.",
11121118
"format": "int32",
1119+
"title": "Authentication required",
11131120
"type": "integer"
11141121
},
11151122
{
11161123
"const": -32002,
11171124
"description": "**Resource not found**: A given resource, such as a file, was not found.",
11181125
"format": "int32",
1126+
"title": "Resource not found",
11191127
"type": "integer"
11201128
},
11211129
{

src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ fn error_code_transform(schema: &mut Schema) {
255255
.as_str()
256256
.expect("Unexpected type for description")
257257
.to_owned();
258+
schema.insert("title".into(), code.to_string().into());
258259
description.insert_str(0, &format!("**{code}**: "));
259260
schema.insert("description".into(), description.into());
260261
schema.insert("const".into(), i32::from(code).into());

0 commit comments

Comments
 (0)