Skip to content

Commit a4cf60a

Browse files
committed
Clean up code structure to use try/catch/await
1 parent f407ecb commit a4cf60a

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

packages/webpack-plugin/src/webpack4and5.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,26 @@ export function sentryWebpackPluginFactory({
281281
const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
282282
const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
283283

284-
sentryBuildPluginManager
285-
.createRelease()
286-
.then(async () => {
284+
const run = async (): Promise<void> => {
285+
try {
286+
await sentryBuildPluginManager.createRelease();
287287
if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
288288
const outputPath = compilation.outputOptions.path ?? path.resolve();
289289
const buildArtifacts = Object.keys(compilation.assets).map((asset) =>
290290
path.join(outputPath, asset)
291291
);
292292
await upload(buildArtifacts);
293293
}
294-
})
295-
.finally(async () => {
294+
} finally {
296295
freeGlobalDependencyOnBuildArtifacts();
297296
await sentryBuildPluginManager.deleteArtifacts();
298-
})
299-
.then(
300-
() => callback(),
301-
(err: Error) => callback(err)
302-
);
297+
}
298+
};
299+
300+
run().then(
301+
() => callback(),
302+
(err: Error) => callback(err)
303+
);
303304
}
304305
);
305306

0 commit comments

Comments
 (0)