-
Notifications
You must be signed in to change notification settings - Fork 38
Stack tracing / debug dump of intermediate files #1227
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
Open
harmony7
wants to merge
12
commits into
main
Choose a base branch
from
kats/stack-tracing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+786
−92
Open
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
829982b
cleanup: remove unused catch param
harmony7 646a319
--enable-stack-traces and --debug-intermediate-files
harmony7 0e3ae3b
Merge branch 'main' into kats/stack-tracing
TartanLlama 7c91447
format files
harmony7 1430d64
fixed missing null check
harmony7 94c0f65
Merge branch 'main' into kats/stack-tracing
harmony7 b7fb6b7
Format
TartanLlama 9212c72
Add docs
harmony7 e47411f
Merge branch 'main' into kats/stack-tracing
harmony7 308a8fc
apply suggestions from review
harmony7 51af407
Merge branch 'main' into kats/stack-tracing
harmony7 982d756
Merge branch 'main' into kats/stack-tracing
harmony7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| hide_title: false | ||
| hide_table_of_contents: false | ||
| pagination_next: null | ||
| pagination_prev: null | ||
| --- | ||
| # mapAndLogError | ||
|
|
||
| The **`mapAndLogError()`** function calls `mapError` on an `Error` object and sends the output to standard error. This includes the error name, message, and a call stack. | ||
|
|
||
| If `--enable-stack-traces` is specified during build, the call stack will be mapped using source maps. | ||
|
|
||
| If `--enable-stack-traces` is specified and `--exclude-sources` is not specified during build, then this will also include a code dump of neighboring lines of user code. | ||
harmony7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Syntax | ||
|
|
||
| ```js | ||
| mapAndLogError(error) | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
| - `error` _: Error _ or _string_ | ||
| - The error to retrieve information about. If a `string` is provided, then it is first converted to an `Error`. | ||
|
|
||
| ### Return value | ||
|
|
||
| `undefined`. | ||
|
|
||
| ## Examples | ||
|
|
||
| In this example, build the application using the `--enable-stack-traces` flag. | ||
|
|
||
| ```js | ||
| addEventListener('fetch', e => e.respondWith(handler(e))); | ||
| async function handler(event) { | ||
| try { | ||
| throw new TypeError('foo'); | ||
| } catch (err) { | ||
| mapAndLogError(mapError(err)); | ||
| } | ||
| return new Response('ok'); | ||
| } | ||
| ``` | ||
|
|
||
| The following is output to the error log. | ||
|
|
||
| ``` | ||
| TypeError: foo | ||
| at handler (src/index.ts:4:11) | ||
| 1 | addEventListener('fetch', e => e.respondWith(handler(e))); | ||
| 2 | async function handler(event) { | ||
| 3 | try { | ||
| > 4 | throw new TypeError('foo'); | ||
| ^ | ||
| 5 | } catch (err) { | ||
| 6 | mapAndLogError(mapError(err)); | ||
| 7 | } | ||
| at src/index.ts:1:45 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| hide_title: false | ||
| hide_table_of_contents: false | ||
| pagination_next: null | ||
| pagination_prev: null | ||
| --- | ||
| # mapError | ||
|
|
||
| The **`mapError()`** function extracts information from an `Error` object as a human-readable array of strings. This includes the error name, message, and a call stack. | ||
|
|
||
| If `--enable-stack-traces` is specified during build, the call stack will be mapped using source maps. | ||
harmony7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| If `--enable-stack-traces` is specified and `--exclude-sources` is not specified during build, then this will also include a code dump of neighboring lines of user code. | ||
harmony7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Syntax | ||
|
|
||
| ```js | ||
| mapError(error) | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
| - `error` _: Error _ or _string_ | ||
| - The error to retrieve information about. If a `string` is provided, then it is first converted to an `Error`. | ||
|
|
||
| ### Return value | ||
|
|
||
| Returns an array of `string` | ||
harmony7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Examples | ||
|
|
||
| In this example, build the application using the `--enable-stack-traces` flag. | ||
|
|
||
| ```js | ||
| addEventListener('fetch', e => e.respondWith(handler(e))); | ||
| async function handler(event) { | ||
| try { | ||
| throw new TypeError('foo'); | ||
| } catch (err) { | ||
| console.error(mapError(err)); | ||
| } | ||
| return new Response('ok'); | ||
| } | ||
| ``` | ||
|
|
||
| The following is output to the error log. | ||
|
|
||
| ``` | ||
| TypeError: foo | ||
| at handler (src/index.ts:4:11) | ||
| 1 | addEventListener('fetch', e => e.respondWith(handler(e))); | ||
| 2 | async function handler(event) { | ||
| 3 | try { | ||
| > 4 | throw new TypeError('foo'); | ||
| ^ | ||
| 5 | } catch (err) { | ||
| 6 | console.error(mapError(err)); | ||
| 7 | } | ||
| at src/index.ts:1:45 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.