Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: displaying errors for apps not installed from Marketplace #15075

Merged
merged 5 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/apps/client/admin/appManage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down
20 changes: 16 additions & 4 deletions app/apps/server/communication/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down