diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-04-24 15:46:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 19:46:08 +0000 |
commit | a6c24729491b90da7c6d6ec78b2ea6662e92cb80 (patch) | |
tree | 3b60d010cc1d4284bb1decf0980be3e134af9710 | |
parent | 2f8825a935bfdf21ca592284556cd86c1552ac8d (diff) |
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)
```
-rw-r--r-- | cli/lsp/tsc.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 3f87c6600..ef096ab8b 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -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(); } } |