Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling (strings, pain to refactor) #85

Open
dcatki opened this issue Aug 12, 2024 · 2 comments
Open

Error handling (strings, pain to refactor) #85

dcatki opened this issue Aug 12, 2024 · 2 comments
Assignees

Comments

@dcatki
Copy link
Collaborator

dcatki commented Aug 12, 2024

No description provided.

@8e8b2c
Copy link
Collaborator

8e8b2c commented Aug 14, 2024

Some options:

Error details as delimited json string

Since WasmError encodes all guest errors as a string, we could makes error details easier to parse by encoding as a json object within the message itself. E.g. instead of the js client receiving:
{"name":"internal_error","message":"Source chain error: InvalidCommit error: Recipe needs at least 1 trusted author"}
It could instead receive:
{"name":"internal_error","message":"Source chain error: InvalidCommit error: __ERR_START__{"type":"InvalidRecipe","reasons":[{"type":"NoTrustedAuthors"},{"type":"UndeclaredVar","var_name":"foo"}]}__ERR_END__"}

And to complement this we could generate TS counterparts:

type InvalidRecipeReason = 
  | { type: "NoTrustedAuthors" }
  | { type: "UndeclaredVar", var_name: string }
  // ...
  
type HoloomError = 
  | { type: "InvalidRecipe", reasons: InvalidRecipeReason[] }
  // ...

Extracting this information can then be done by parsing the string between the delimiters.

Return ExternResult<SomeNestedTypedResult>

Coordinator functions could return errors as 'successes' to take advantage of builtin msgpack serialisation. One advantage is that is becomes simpler to bind esoteric error type to only their relevant functions.

The biggest flaw with this approach is that most hdk functions already return ExternResult, so we're already forced to be interpreting an error string much of the time.

@8e8b2c
Copy link
Collaborator

8e8b2c commented Aug 19, 2024

Spike for setting out validation rejection reason pattern:
#101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants