Skip to content

Commit

Permalink
chore(lsp): Print out stack trace if exception occurs in TS request (d…
Browse files Browse the repository at this point in the history
…enoland#23543)

Before this PR, there would just be an uninformative "Error occurred"
message, after this PR you'll get a stack trace in the LSP output window
like this:

```text
Error during TS request "$getSupportedCodeFixes":
  Error: i threw an exception
    at serverRequest (ext:deno_tsc/99_main_compiler.js:1089:11)
```
  • Loading branch information
nathanwhit committed Apr 24, 2024
1 parent 2f8825a commit a6c2472
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4280,6 +4280,20 @@ impl TscRuntime {

server_request_fn.call(tc_scope, undefined, &args);
if tc_scope.has_caught() && !tc_scope.has_terminated() {
if let Some(stack_trace) = tc_scope.stack_trace() {
lsp_warn!(
"Error during TS request \"{method}\":\n {}",
stack_trace.to_rust_string_lossy(tc_scope),
);
} else {
lsp_warn!(
"Error during TS request \"{method}\":\n {}",
tc_scope
.exception()
.map(|exc| exc.to_rust_string_lossy(tc_scope))
.unwrap_or_default(),
);
}
tc_scope.rethrow();
}
}
Expand Down

0 comments on commit a6c2472

Please sign in to comment.