Skip to content

Commit 555b602

Browse files
committed
Report exceptions to telemetry in init Action
1 parent f32426b commit 555b602

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

lib/init-action.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init-action.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as path from "path";
33
import * as core from "@actions/core";
44

55
import {
6-
ActionStatus,
76
createStatusReportBase,
87
getActionsStatus,
98
getActionVersion,
@@ -95,20 +94,22 @@ interface InitToolsDownloadFields {
9594
tools_feature_flags_valid?: boolean;
9695
}
9796

98-
async function sendInitStatusReport(
99-
actionStatus: ActionStatus,
97+
async function sendCompletedStatusReport(
10098
startedAt: Date,
10199
config: configUtils.Config | undefined,
102100
toolsDownloadDurationMs: number | undefined,
103101
toolsFeatureFlagsValid: boolean | undefined,
104102
toolsSource: ToolsSource,
105103
toolsVersion: string,
106-
logger: Logger
104+
logger: Logger,
105+
error?: Error
107106
) {
108107
const statusReportBase = await createStatusReportBase(
109108
"init",
110-
actionStatus,
111-
startedAt
109+
getActionsStatus(error),
110+
startedAt,
111+
error?.message,
112+
error?.stack
112113
);
113114

114115
const workflowLanguages = getOptionalInput("languages");
@@ -366,23 +367,21 @@ async function run() {
366367

367368
core.setOutput("codeql-path", config.codeQLCmd);
368369
} catch (error) {
369-
core.setFailed(String(error));
370-
370+
core.setFailed(error instanceof Error ? error.message : String(error));
371371
console.log(error);
372-
await sendInitStatusReport(
373-
getActionsStatus(error),
372+
await sendCompletedStatusReport(
374373
startedAt,
375374
config,
376375
toolsDownloadDurationMs,
377376
toolsFeatureFlagsValid,
378377
toolsSource,
379378
toolsVersion,
380-
logger
379+
logger,
380+
error instanceof Error ? error : new Error(String(error))
381381
);
382382
return;
383383
}
384-
await sendInitStatusReport(
385-
"success",
384+
await sendCompletedStatusReport(
386385
startedAt,
387386
config,
388387
toolsDownloadDurationMs,

0 commit comments

Comments
 (0)