0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-09 05:36:49 -04:00
deno/core
Jan Špaček 642118fdeb
fix(core) Include causes when converting anyhow errors to JS exceptions (#16397)
When an op returns an `anyhow` error with a cause (usually added using
the `.context()` method), the `Error` thrown into JavaScript contains
only the message of the outernmost error in the chain.

This PR simply changes the formatting of `anyhow::Error` from `"{}"` to
`"{:#}"`:

This significantly improves errors for code that embeds Deno and defines
custom ops. For example, in
[chiselstrike/chiselstrike](https://github.com/chiselstrike/chiselstrike),
this PR improves an error message like

```
Error: could not plan migration
```

to

```
Error: could not plan migration: could not migrate table for entity "E": could not add column for field "title": the field does not have a default value
```
2022-10-26 17:30:44 +02:00
..
examples bench: avoid port collision (#16285) 2022-10-15 13:35:04 +02:00
00_primordials.js
01_core.js perf(ext/streams): fast path when consuming body of tee'd stream (#16329) 2022-10-24 13:13:20 +02:00
02_error.js
async_cancel.rs
async_cell.rs
bindings.rs Revert realms from deno_core (#16366) 2022-10-21 08:24:22 +05:30
Cargo.toml fix: upgrade swc_ecma_parser to 0.122.19 - deno_ast 0.20 (#16406) 2022-10-25 11:55:57 -04:00
encode_decode_test.js
error.rs fix(core) Include causes when converting anyhow errors to JS exceptions (#16397) 2022-10-26 17:30:44 +02:00
error_builder_test.js
error_codes.rs
extensions.rs
flags.rs
gotham_state.rs
icudtl.dat
inspector.rs
internal.d.ts
io.rs feat(core): improve resource read & write traits (#16115) 2022-10-09 14:49:25 +00:00
lib.deno_core.d.ts chore(core): remove core.opSync (#16379) 2022-10-21 19:35:23 +05:30
lib.rs feat(core): improve resource read & write traits (#16115) 2022-10-09 14:49:25 +00:00
module_specifier.rs
modules.rs refactor(core): use isolate get_data/set_data instead of slots (#16286) 2022-10-15 16:01:01 +02:00
normalize_path.rs
ops.rs fix(core) Include causes when converting anyhow errors to JS exceptions (#16397) 2022-10-26 17:30:44 +02:00
ops_builtin.rs feat(core): add Deno.core.writeAll(rid, chunk) (#16228) 2022-10-10 10:28:35 +02:00
ops_builtin_v8.rs perf(core): do not drive JsInspector by default (#16410) 2022-10-26 17:07:50 +05:30
ops_metrics.rs
README.md chore(core): remove core.opSync (#16379) 2022-10-21 19:35:23 +05:30
resources.rs fix(ext/net): return an error from startTls and serveHttp if the original connection is captured elsewhere (#16242) 2022-10-18 11:28:27 +09:00
runtime.rs fix(core) Include causes when converting anyhow errors to JS exceptions (#16397) 2022-10-26 17:30:44 +02:00
serialize_deserialize_test.js
source_map.rs

Deno Core Crate

crates docs

The main dependency of this crate is rusty_v8, which provides the V8-Rust bindings.

This Rust crate contains the essential V8 bindings for Deno's command-line interface (Deno CLI). The main abstraction here is the JsRuntime which provides a way to execute JavaScript.

The JsRuntime implements an event loop abstraction for the executed code that keeps track of all pending tasks (async ops, dynamic module loads). It is user's responsibility to drive that loop by using JsRuntime::run_event_loop method - it must be executed in the context of Rust's future executor (eg. tokio, smol).

Rust functions can be registered in JavaScript using deno_core::Extension. Use the Deno.core.ops.op_name() and Deno.core.opAsync("op_name", ...) functions to trigger the op function callback. A conventional way to write ops is using the deno_ops crate.

Documentation for this crate is thin at the moment. Please see hello_world.rs and http_bench_json_ops.rs as examples of usage.

TypeScript support and lots of other functionality are not available at this layer. See the CLI for that.