diff --git a/app/apps/client/admin/appManage.js b/app/apps/client/admin/appManage.js index c6d2d73dbdbd..460bea32932e 100644 --- a/app/apps/client/admin/appManage.js +++ b/app/apps/client/admin/appManage.js @@ -95,6 +95,10 @@ const attachMarketplaceInformation = async (appId, version, _app) => { attachBundlesApps(bundledIn, _app); } catch (error) { + if (error.xhr && error.xhr.status === 404) { + return; + } + handleAPIError(error); } }; diff --git a/app/apps/server/communication/rest.js b/app/apps/server/communication/rest.js index 924a546575a2..63e8502f972e 100644 --- a/app/apps/server/communication/rest.js +++ b/app/apps/server/communication/rest.js @@ -292,6 +292,20 @@ export class AppsRestApi { }, }); + const handleError = (message, e) => { + orchestrator.getRocketChatLogger().error(message, e.response.data); + + if (e.response.statusCode >= 500 && e.response.statusCode <= 599) { + return API.v1.internalError(); + } + + if (e.response.statusCode === 404) { + return API.v1.notFound(); + } + + return API.v1.failure(); + }; + this.api.addRoute(':id', { authRequired: true, permissionsRequired: ['manage-apps'] }, { get() { if (this.queryParams.marketplace && this.queryParams.version) { @@ -309,8 +323,7 @@ export class AppsRestApi { headers, }); } catch (e) { - orchestrator.getRocketChatLogger().error('Error getting the App information from the Marketplace:', e.response.data); - return API.v1.internalError(); + return handleError('Error getting the App information from the Marketplace:', e); } if (!result || result.statusCode !== 200 || result.data.length === 0) { @@ -336,8 +349,7 @@ export class AppsRestApi { headers, }); } catch (e) { - orchestrator.getRocketChatLogger().error('Error getting the App update info from the Marketplace:', e.response.data); - return API.v1.internalError(); + return handleError('Error getting the App update info from the Marketplace:', e); } if (result.statusCode !== 200 || result.data.length === 0) {