Skip to content

Commit e408152

Browse files
encourate customers to debugging errors
1 parent 021a385 commit e408152

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

Diff for: visual-js/visual-snapshots/src/app/pdf-handler.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export interface PdfCommandParams
1212
concurrency: number;
1313
}
1414

15-
export enum PdfCommandStatus {
16-
SUCCESS,
17-
FAILURE,
18-
}
19-
2015
export class PdfCommandHandler {
2116
constructor(
2217
private readonly visualSnapshotsApi: VisualSnapshotsApi,
@@ -26,13 +21,12 @@ export class PdfCommandHandler {
2621
public async handle(
2722
globsOrDirs: string[],
2823
params: PdfCommandParams
29-
): Promise<PdfCommandStatus> {
24+
): Promise<void> {
3025
const pdfFilePaths = await getFiles(globsOrDirs, "*.pdf");
3126

3227
const buildId =
3328
params.buildId ?? (await this.visualSnapshotsApi.createBuild(params));
3429

35-
let status: PdfCommandStatus;
3630
try {
3731
await this.pdfSnapshotUploader.uploadSnapshots({
3832
buildId,
@@ -41,14 +35,10 @@ export class PdfCommandHandler {
4135
testNameFormat: params.testName,
4236
snapshotNameFormat: params.snapshotName,
4337
});
44-
status = PdfCommandStatus.SUCCESS;
45-
} catch (_) {
46-
status = PdfCommandStatus.FAILURE;
47-
}
48-
49-
if (!params.buildId) {
50-
await this.visualSnapshotsApi.finishBuild(buildId);
38+
} finally {
39+
if (!params.buildId) {
40+
await this.visualSnapshotsApi.finishBuild(buildId);
41+
}
5142
}
52-
return status;
5343
}
5444
}

Diff for: visual-js/visual-snapshots/src/commands/pdf.ts

+4-16
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import {
1212
suiteNameOption,
1313
usernameOption,
1414
} from "./options.js";
15-
import {
16-
PdfCommandHandler,
17-
PdfCommandParams,
18-
PdfCommandStatus,
19-
} from "../app/pdf-handler.js";
15+
import { PdfCommandHandler, PdfCommandParams } from "../app/pdf-handler.js";
2016
import { EOL } from "os";
2117
import { VisualSnapshotsApi } from "../api/visual-snapshots-api.js";
2218
import { initializeVisualApi } from "../api/visual-client.js";
@@ -71,19 +67,11 @@ export const pdfCommand = (clientVersion: string) => {
7167

7268
new PdfCommandHandler(visualSnapshotsApi, pdfSnapshotUploader)
7369
.handle(globsOrDirs, params)
74-
.then((status: PdfCommandStatus) => {
75-
if (status == PdfCommandStatus.SUCCESS) {
76-
console.info("Successfully created PDF snapshots.");
77-
} else {
78-
console.error(
79-
"At least one PDF snapshot creation failed. Please contact Sauce Labs customer support."
80-
);
81-
}
70+
.then(() => {
71+
console.info("Successfully created PDF snapshots.");
8272
})
8373
.catch((err) => {
84-
console.error(
85-
`An unexpected error occured when creating PDF snapshots: ${err}. Please contact Sauce Labs customer support.`
86-
);
74+
console.error(`At least one PDF snapshot creation failed: ${err}.`);
8775
});
8876
});
8977
};

0 commit comments

Comments
 (0)