Skip to content

Deno 1.10 Extension API custom errors #10671

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

Closed
rracariu opened this issue May 17, 2021 · 3 comments
Closed

Deno 1.10 Extension API custom errors #10671

rracariu opened this issue May 17, 2021 · 3 comments
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed

Comments

@rracariu
Copy link

In Deno 1.10.1 returning an error from an Op causes an error in Deno.

thread '<unnamed>' panicked at 'Error '`my_error` err: Generic("Some error.")' contains boxed error of unknown type:
  CustomError { class: "Error", message: "`my_error` err: Generic(\"Some error.\")" }', cli\errors.rs:35:7

This is fixable by manually configuring the error resolving callback as:

fn op_name(
                state: &mut deno_core::OpState,
                args: (),
                _zero_copy: Option<deno_core::ZeroCopyBuf>,
            )
......
state.get_error_class_fn = &my_error_class_name

Expecting that the error class resolving callback should be set by default.

@AaronO
Copy link
Contributor

AaronO commented May 17, 2021

I had explained this error to @DjDeveloperr on Discord.

This issue is due to TypeIds not being shared (and thus "stable") between deno and the extension DLL, so ref downcasting and other such operations (e.g: GothamState access) may fail.

This and #10670 will have to be fixed by a more comprehensive plugins rewrite (which I have outlined and discussed in #dev)

@rracariu
Copy link
Author

rracariu commented May 17, 2021

Ouch, yeah - noticed that basically there are object duplicated in plugin and Deno, due to linking Deno core, which also exploded the size of the plugin.

I see now what is the cause, this would need to be simplified to a more C like interface that relies on some form of dynamic traits.

What I really like about the new API is that it allows exposing arguments and return types naturally to Ops (based on serde::v8) and that it takes care of the Async dispatching machinery. I hope the fixed solution will try to keep these features in some form...

@lucacasonato lucacasonato added bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed labels Jun 8, 2021
@bartlomieju
Copy link
Member

In light of plugin API removal in #11152 this issue is no longer relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed
Projects
None yet
Development

No branches or pull requests

4 participants