Skip to content

Commit bef68b7

Browse files
committed
feat(credential): Allow any ErrorKind to have a custom error
1 parent a716f65 commit bef68b7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

credential/cargo-credential/src/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ impl Error {
2929
}
3030
}
3131

32+
pub fn with_kind(mut self, kind: ErrorKind) -> Self {
33+
self.kind = kind;
34+
self
35+
}
36+
3237
pub fn kind(&self) -> ErrorKind {
3338
self.kind
3439
}

src/doc/src/reference/credential-provider-protocol.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ the provider wants to generate tokens that are scoped to specific operations.
163163
```javascript
164164
{"Err":{
165165
"kind":"url-not-supported"
166+
// (Optional) Error message string to be displayed
167+
"message": "free form string error message",
168+
// (Optional) Detailed cause chain for the error (optional)
169+
"caused-by": ["cause 1", "cause 2"]
166170
}}
167171
```
168172
Sent if the credential provider is designed
@@ -177,6 +181,10 @@ available.
177181
{"Err":{
178182
// Error: The credential could not be found in the provider.
179183
"kind":"not-found"
184+
// (Optional) Error message string to be displayed
185+
"message": "free form string error message",
186+
// (Optional) Detailed cause chain for the error (optional)
187+
"caused-by": ["cause 1", "cause 2"]
180188
}}
181189
```
182190
Sent if the credential could not be found. This is expected for
@@ -190,6 +198,10 @@ requests where there is nothing found to erase.
190198
{"Err":{
191199
// Error: The credential could not be found in the provider.
192200
"kind":"operation-not-supported"
201+
// (Optional) Error message string to be displayed
202+
"message": "free form string error message",
203+
// (Optional) Detailed cause chain for the error (optional)
204+
"caused-by": ["cause 1", "cause 2"]
193205
}}
194206
```
195207
Sent if the credential provider does not support the requested operation.

0 commit comments

Comments
 (0)