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

Update error message handling #3173

Merged
merged 1 commit into from
Jun 15, 2020
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
3 changes: 1 addition & 2 deletions app/scripts/controllers/newfromtemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ angular.module('openshiftConsole')
$scope.template = CachedTemplateService.getTemplate();
// In case the template can be loaded from 'CachedTemaplteService', show an alert and disable "Create" button.
if (_.isEmpty($scope.template)) {

sessionStorage.setItem("error_description", "Template wasn't found in cache.");
var redirect = URI('error').query({
error: "not_found",
error_description: "Template wasn't found in cache."
}).toString();
$location.url(redirect);
}
Expand Down
5 changes: 3 additions & 2 deletions app/scripts/controllers/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module('openshiftConsole')
.controller('ErrorController', function ($scope, $window) {
var params = URI(window.location.href).query(true);
var error = params.error;
var error_description = sessionStorage.getItem("error_description");

switch(error) {
case 'access_denied':
Expand All @@ -33,8 +34,8 @@ angular.module('openshiftConsole')
$scope.errorMessage = "An error has occurred";
}

if (params.error_description) {
$scope.errorDetails = params.error_description;
if (error_description) {
$scope.errorDetails = error_description;
}

$scope.reloadConsole = function() {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/util/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ angular.module('openshiftConsole')

})
.catch(function(rejection) {
sessionStorage.setItem("error_description", rejection.error_description || "");
var redirect = URI('error').query({
error: rejection.error || "",
error_description: rejection.error_description || "",
error_uri: rejection.error_uri || ""
}).toString();
authLogger.error("OAuthController, error", rejection, "redirecting", redirect);
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/services/navigate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ angular.module("openshiftConsole")
* @returns {undefined}
*/
toErrorPage: function(message, errorCode, reload) {
sessionStorage.setItem("error_description", message);
var redirect = URI('error').query({
error_description: message,
error: errorCode
}).toString();
if (!reload) {
Expand Down
14 changes: 7 additions & 7 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1899,8 +1899,8 @@ return _.get(t, "isPipeline") ? "pipelines" : _.isObject(e) && l(e) ? "pipelines
};
return {
toErrorPage: function(n, r, a) {
sessionStorage.setItem("error_description", n);
var o = URI("error").query({
error_description: n,
error: r
}).toString();
a ? t.location.href = o : e.url(o).replace();
Expand Down Expand Up @@ -8476,9 +8476,9 @@ maxWait: 250
c.toErrorPage("Cannot create from template: the specified template could not be retrieved.");
}); else {
if (a.template = i.getTemplate(), _.isEmpty(a.template)) {
sessionStorage.setItem("error_description", "Template wasn't found in cache.");
var n = URI("error").query({
error: "not_found",
error_description: "Template wasn't found in cache."
error: "not_found"
}).toString();
t.url(n);
}
Expand Down Expand Up @@ -8549,16 +8549,16 @@ error: "user_fetch_failed"
c.error("OAuthController, error fetching user", e, "redirecting", n), t.replace(), t.url(n);
});
}).catch(function(e) {
sessionStorage.setItem("error_description", e.error_description || "");
var n = URI("error").query({
error: e.error || "",
error_description: e.error_description || "",
error_uri: e.error_uri || ""
}).toString();
c.error("OAuthController, error", e, "redirecting", n), t.replace(), t.url(n);
});
} ]), angular.module("openshiftConsole").controller("ErrorController", [ "$scope", "$window", function(e, t) {
var n = URI(window.location.href).query(!0);
switch (n.error) {
var n = URI(window.location.href).query(!0).error, r = sessionStorage.getItem("error_description");
switch (n) {
case "access_denied":
e.errorMessage = "Access denied";
break;
Expand All @@ -8582,7 +8582,7 @@ break;
default:
e.errorMessage = "An error has occurred";
}
n.error_description && (e.errorDetails = n.error_description), e.reloadConsole = function() {
r && (e.errorDetails = r), e.reloadConsole = function() {
t.location.href = "/";
};
} ]), angular.module("openshiftConsole").controller("LogoutController", [ "$scope", "$routeParams", "$log", "AuthService", "AUTH_CFG", function(e, t, n, r, a) {
Expand Down