File tree Expand file tree Collapse file tree 5 files changed +14
-15
lines changed
Expand file tree Collapse file tree 5 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 88} from "vscode" ;
99import { showAndLogErrorMessage , showAndLogWarningMessage } from "./helpers" ;
1010import { extLogger } from "./common" ;
11- import { getErrorMessage , getErrorStack } from "./pure/helpers-pure" ;
11+ import { asError , getErrorMessage , getErrorStack } from "./pure/helpers-pure" ;
1212import { telemetryListener } from "./telemetry" ;
1313
1414export class UserCancellationException extends Error {
@@ -126,7 +126,7 @@ export function commandRunner(
126126 return await task ( ...args ) ;
127127 } catch ( e ) {
128128 const errorMessage = `${ getErrorMessage ( e ) || e } (${ commandId } )` ;
129- error = e instanceof Error ? e : new Error ( errorMessage ) ;
129+ error = asError ( e ) ;
130130 const errorStack = getErrorStack ( e ) ;
131131 if ( e instanceof UserCancellationException ) {
132132 // User has cancelled this action manually
@@ -179,7 +179,7 @@ export function commandRunnerWithProgress<R>(
179179 return await withProgress ( progressOptionsWithDefaults , task , ...args ) ;
180180 } catch ( e ) {
181181 const errorMessage = `${ getErrorMessage ( e ) || e } (${ commandId } )` ;
182- error = e instanceof Error ? e : new Error ( errorMessage ) ;
182+ error = asError ( e ) ;
183183 const errorStack = getErrorStack ( e ) ;
184184 if ( e instanceof UserCancellationException ) {
185185 // User has cancelled this action manually
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import {
1919} from "./archive-filesystem-provider" ;
2020import { DisposableObject } from "./pure/disposable-object" ;
2121import { Logger , extLogger } from "./common" ;
22- import { getErrorMessage } from "./pure/helpers-pure" ;
22+ import { asError , getErrorMessage } from "./pure/helpers-pure" ;
2323import { QueryRunner } from "./queryRunner" ;
2424import { pathsEqual } from "./pure/files" ;
2525
@@ -370,7 +370,7 @@ export class DatabaseItemImpl implements DatabaseItem {
370370 this . _error = undefined ;
371371 } catch ( e ) {
372372 this . _contents = undefined ;
373- this . _error = e instanceof Error ? e : new Error ( String ( e ) ) ;
373+ this . _error = asError ( e ) ;
374374 throw e ;
375375 }
376376 } finally {
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ import {
7373 showInformationMessageWithAction ,
7474 tmpDir ,
7575} from "./helpers" ;
76- import { asError , assertNever , getErrorMessage } from "./pure/helpers-pure" ;
76+ import { assertNever , getErrorMessage } from "./pure/helpers-pure" ;
7777import { spawnIdeServer } from "./ide-server" ;
7878import { ResultsView } from "./interface" ;
7979import { WebviewReveal } from "./interface-utils" ;
@@ -771,9 +771,7 @@ async function activateWithInstalledDistribution(
771771 // Note we must update the query history view after showing results as the
772772 // display and sorting might depend on the number of results
773773 } catch ( e ) {
774- const err = asError ( e ) ;
775- err . message = `Error running query: ${ err . message } ` ;
776- item . failureReason = err . message ;
774+ item . failureReason = `Error running query: ${ getErrorMessage ( e ) } ` ;
777775 throw e ;
778776 } finally {
779777 await qhm . refreshTreeView ( ) ;
Original file line number Diff line number Diff line change @@ -46,14 +46,14 @@ export const REPO_REGEX = /^[a-zA-Z0-9-_\.]+\/[a-zA-Z0-9-_\.]+$/;
4646 */
4747export const OWNER_REGEX = / ^ [ a - z A - Z 0 - 9 -_ \. ] + $ / ;
4848
49- export function getErrorMessage ( e : any ) {
49+ export function getErrorMessage ( e : unknown ) {
5050 return e instanceof Error ? e . message : String ( e ) ;
5151}
5252
53- export function getErrorStack ( e : any ) {
53+ export function getErrorStack ( e : unknown ) {
5454 return e instanceof Error ? e . stack ?? "" : "" ;
5555}
5656
57- export function asError ( e : any ) : Error {
57+ export function asError ( e : unknown ) : Error {
5858 return e instanceof Error ? e : new Error ( String ( e ) ) ;
5959}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ import { DatabaseManager } from "./databases";
3333import { DecodedBqrsChunk } from "./pure/bqrs-cli-types" ;
3434import { extLogger , Logger } from "./common" ;
3535import { generateSummarySymbolsFile } from "./log-insights/summary-parser" ;
36- import { asError } from "./pure/helpers-pure" ;
36+ import { getErrorMessage } from "./pure/helpers-pure" ;
3737
3838/**
3939 * run-queries.ts
@@ -270,9 +270,10 @@ export class QueryEvaluationInfo {
270270 ) ;
271271 return this . evalLogSummaryPath ;
272272 } catch ( e ) {
273- const err = asError ( e ) ;
274273 void showAndLogWarningMessage (
275- `Failed to generate human-readable structured evaluator log summary. Reason: ${ err . message } ` ,
274+ `Failed to generate human-readable structured evaluator log summary. Reason: ${ getErrorMessage (
275+ e ,
276+ ) } `,
276277 ) ;
277278 return undefined ;
278279 }
You can’t perform that action at this time.
0 commit comments