Skip to content

Commit 489c7be

Browse files
committed
more info about context
Signed-off-by: Leo Valais <[email protected]>
1 parent 3c86cc6 commit 489c7be

File tree

1 file changed

+9
-8
lines changed
  • content/docs/reference/design-docs/editoast-errors

1 file changed

+9
-8
lines changed

content/docs/reference/design-docs/editoast-errors/_index.en.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -241,26 +241,27 @@ Note: it shouldn't be used in `editoast` as we now have enums variants we can `m
241241
#[derive(Debug, thiserror::Error, ViewError)]
242242
enum Error {
243243
#[view_error(user)]
244-
No { because: String }, // { }
244+
NoContext { because: String }, // context = { }
245245

246246
#[view_error(user, context)]
247-
Nein { reasons: Vec<String> }, // { "reasons": [string] }
247+
AllFieldsIntoContext { reasons: Vec<String> }, // context = { "reasons": [string] }
248248

249-
// select (and maybe rename) some fields
249+
// select (and maybe rename) some fields to include to the context
250250
#[view_error(user, context(reason, recovery_id = "recovery"))]
251-
QueNo {
251+
SomeFieldsIntoContext {
252252
reason: String,
253253
recovery_id: String,
254-
not_serializable: mspc::Send<()>
255-
},
254+
not_serializable: mpsc::Sender<()>,
255+
not_wanted: u64,
256+
}, // context = { "reason": string, "recovery": string }
256257
}
257258

258259
// with a provider function
259260
#[derive(Debug, thiserror::Error, ViewError)]
260261
#[view_error(context_with = context_provider)]
261262
enum Error {
262-
Nao(String),
263-
Nee(String, u64)
263+
Variant1(String),
264+
Variant2(String, u64)
264265
}
265266

266267
fn context_provider(error: Error) -> HashMap<String, serde_json::Value> {

0 commit comments

Comments
 (0)