Skip to content

Commit

Permalink
Update debugger.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Jun 18, 2024
1 parent 0189dbb commit 7b9fe84
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/runtime/debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,20 @@ Bun automatically loads sourcemaps both at runtime when transpiling files on-dem
To help with debugging, Bun automatically prints a small source-code preview when an unhandled exception or rejection occurs. You can simulate this behavior by calling `Bun.inspect(error)`:

```ts
// Create an error
const err = new Error("Something went wrong");
console.log(Bun.inspect(err, { colors: true }));
```

{% image src="https://github.com/oven-sh/bun/assets/709451/31ab1574-f59c-475b-be2e-f1aba74169bf" width="377" /%}
This prints a syntax-highlighted preview of the source code where the error occurred, along with the error message and stack trace.

```js
1 | // Create an error
2 | const err = new Error("Something went wrong");
^
error: Something went wrong
at file.js:2:13
```

### V8 Stack Traces

Expand Down

0 comments on commit 7b9fe84

Please sign in to comment.