File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,17 @@ impl Error {
9494 Error :: new ( ErrorCode :: AUTH_REQUIRED )
9595 }
9696
97+ /// A given resource, such as a file, was not found.
98+ #[ must_use]
99+ pub fn resource_not_found ( uri : Option < String > ) -> Self {
100+ let err = Error :: new ( ErrorCode :: RESOURCE_NOT_FOUND ) ;
101+ if let Some ( uri) = uri {
102+ err. with_data ( serde_json:: json!( { "uri" : uri } ) )
103+ } else {
104+ err
105+ }
106+ }
107+
97108 /// Converts a standard error into an internal JSON-RPC error.
98109 ///
99110 /// The error's string representation is included as additional data.
@@ -153,6 +164,13 @@ impl ErrorCode {
153164 code : -32000 ,
154165 message : "Authentication required" ,
155166 } ;
167+
168+ /// A given resource, such as a file, was not found.
169+ /// This is an ACP-specific error code in the reserved range.
170+ pub const RESOURCE_NOT_FOUND : ErrorCode = ErrorCode {
171+ code : -32002 ,
172+ message : "Resource not found" ,
173+ } ;
156174}
157175
158176impl From < ErrorCode > for ( i32 , String ) {
Original file line number Diff line number Diff line change @@ -963,6 +963,13 @@ export class RequestError extends Error {
963963 return new RequestError ( - 32000 , "Authentication required" , data ) ;
964964 }
965965
966+ /**
967+ * Resource, such as a file, was not found
968+ */
969+ static resourceNotFound ( uri ?: string ) : RequestError {
970+ return new RequestError ( - 32002 , "Resource not found" , uri && { uri } ) ;
971+ }
972+
966973 toResult < T > ( ) : Result < T > {
967974 return {
968975 error : {
You can’t perform that action at this time.
0 commit comments