1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

chore(lsp): Print out stack trace if exception occurs in TS request (#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)
```
This commit is contained in:
Nathan Whitaker 2024-04-24 15:46:08 -04:00 committed by GitHub
parent 2f8825a935
commit a6c2472949
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4280,6 +4280,20 @@ impl TscRuntime {
server_request_fn.call(tc_scope, undefined, &args); server_request_fn.call(tc_scope, undefined, &args);
if tc_scope.has_caught() && !tc_scope.has_terminated() { 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(); tc_scope.rethrow();
} }
} }