Skip to content

Commit 060d76b

Browse files
committed
api error case fixed
1 parent e01dcdd commit 060d76b

2 files changed

Lines changed: 13 additions & 26 deletions

File tree

src/engine/universal/core/src/engine/engine.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,10 @@ class Engine {
245245
/**
246246
* Returns whether the given process version is currently deployed in the NeoBPMN Engine
247247
*
248-
* @param {string} definitionId the id of the process definition
249248
* @param {string} versionId the version of the process to check
250249
* @returns {boolean} true if the version is deployed, false if it is known but not active
251-
* @throws {Error} if the version has never been deployed to this engine
252250
*/
253-
async isProcessVersionDeployed(definitionId, versionId) {
254-
try {
255-
await distribution.db.getProcessVersion(definitionId, versionId);
256-
} catch {
257-
throw new Error(`Version ${versionId} has never been deployed to this engine.`);
258-
}
259-
251+
async isProcessVersionDeployed(versionId) {
260252
return this._versionProcessMapping[versionId]?.isDeployed() ?? false;
261253
}
262254

src/engine/universal/distribution/src/routes/ProcessInstanceRoutes.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -463,30 +463,25 @@ module.exports = (path, management) => {
463463

464464
network.get(`${path}/:definitionId/versions/:version/active`, { cors: true }, async (req) => {
465465
const { definitionId, version } = req.params;
466-
const engine = management.getEngineWithDefinitionId(definitionId);
467-
468-
if (!engine) {
469-
return {
470-
statusCode: 200,
471-
mimeType: 'application/json',
472-
response: JSON.stringify({ active: false }),
473-
};
474-
}
475466

476467
try {
477-
return {
478-
statusCode: 200,
479-
mimeType: 'application/json',
480-
response: JSON.stringify({
481-
active: await engine.isProcessVersionDeployed(definitionId, version),
482-
}),
483-
};
484-
} catch (_) {
468+
await db.getProcessVersion(definitionId, version);
469+
} catch {
485470
return {
486471
statusCode: 404,
487472
mimeType: 'text/plain',
488473
response: 'The requested version is not found in this engine.',
489474
};
490475
}
476+
477+
const engine = management.getEngineWithDefinitionId(definitionId);
478+
479+
return {
480+
statusCode: 200,
481+
mimeType: 'application/json',
482+
response: JSON.stringify({
483+
active: engine ? await engine.isProcessVersionDeployed(version) : false,
484+
}),
485+
};
491486
});
492487
};

0 commit comments

Comments
 (0)