diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js index 79b52c4cca..bd8c505a3d 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js @@ -16,5 +16,6 @@ Umbraco.Sys.ServerVariables = { }, umbracoSettings: { "umbracoPath": "/umbraco" - } + }, + isDebuggingEnabled: true }; \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js index ed6fd2fcfa..5ffd67efad 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js @@ -340,6 +340,27 @@ angular.module('umbraco.services') template: 'views/common/dialogs/property.html', show: true }); + }, + + /** + * @ngdoc method + * @name umbraco.services.dialogService#ysodDialog + * @methodOf umbraco.services.dialogService + * + * @description + * Opens a dialog to show a custom YSOD + */ + ysodDialog: function (ysodError) { + + var newScope = $rootScope.$new(); + newScope.error = ysodError; + return openDialog({ + modalClass: "umb-modal wide", + scope: newScope, + //callback: options.callback, + template: 'views/common/dialogs/ysod.html', + show: true + }); } }; }]); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js index 24e258f0ab..7781dc83eb 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js @@ -257,7 +257,7 @@ angular.module('umbraco.services').factory('umbImageHelper', umbImageHelper); * @name umbraco.services.umbRequestHelper * @description A helper object used for sending requests to the server **/ -function umbRequestHelper($http, $q, umbDataFormatter, angularHelper) { +function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogService) { return { /** @@ -319,7 +319,7 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper) { (!queryStrings ? "" : "?" + (angular.isString(queryStrings) ? queryStrings : this.dictionaryToQueryString(queryStrings))); }, - + /** * @ngdoc function * @name umbraco.services.umbRequestHelper#resourcePromise @@ -378,14 +378,23 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper) { //invoke the callback var result = callbacks.error.apply(this, [data, status, headers, config]); - //when there's an erorr... - // TODO: Deal with the error in a global way + //when there's a 500 (unhandled) error show a YSOD overlay if debugging is enabled. + if (status >= 500 && status < 600 && Umbraco.Sys.ServerVariables["isDebuggingEnabled"] === true) { - //return an error object including the error message for UI - deferred.reject({ - errorMsg: result.errorMsg, - data: result.data - }); + dialogService.ysodDialog({ + errorMsg: result.errorMsg, + data: result.data + }); + } + else { + + //return an error object including the error message for UI + deferred.reject({ + errorMsg: result.errorMsg, + data: result.data + }); + + } }); diff --git a/src/Umbraco.Web.UI.Client/src/less/modals.less b/src/Umbraco.Web.UI.Client/src/less/modals.less index 89f761f4a0..152702b4d0 100644 --- a/src/Umbraco.Web.UI.Client/src/less/modals.less +++ b/src/Umbraco.Web.UI.Client/src/less/modals.less @@ -95,6 +95,10 @@ } +.umb-modal.fade.in.wide { + margin-left: -640px; + width: 640px !important; +} /* MEDIA PICKER */ .umb-modal .umb-btn-toolbar { @@ -173,3 +177,35 @@ .umb-modal .thumbnails > li.folder a:hover { text-decoration: none } + + +/* YSOD */ + +/* These styles are an exact replica of a real .Net YSOD */ +.umb-modal .ysod { + font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;padding:5px; +} +.umb-modal .ysod > div { + font-family: Arial, Helvetica, Geneva, SunSans-Regular, sans-serif; + line-height: 13px; + font-size: 11px; +} +.umb-modal .ysod hr { + margin: 0px; + color: silver; + background-color: silver; + height: 1px; +} +.umb-modal .ysod p {font-family:"Verdana";font-weight:normal;color:black;} +.umb-modal .ysod b {font-family:"Verdana";font-weight:bold;color:black;} +.umb-modal .ysod h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red;padding: 0px;text-transform: none !important;margin: 0px; } +.umb-modal .ysod h2 { font-style:italic; font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon; } +.umb-modal .ysod pre {border:none;font-family:"Consolas","Lucida Console",Monospace;font-size:13px;margin:0;padding:0.5em;line-height:17px;} +.umb-modal .ysod .marker {font-weight: bold; color: black;text-decoration: none;} +.umb-modal .ysod .version {color: gray;} +.umb-modal .ysod .error {margin-bottom: 10px;} +.umb-modal .ysod .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; } +.umb-modal .ysod table {background-color:#ffffcc;width:100%;} +.umb-modal .ysod table pre {background-color: inherit;} +.umb-modal .ysod table code {background-color: inherit;} +.umb-modal .ysod a.btn { margin-top:10px;margin-right:10px;float:right;} \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/ysod.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/ysod.controller.js new file mode 100644 index 0000000000..46abf5c88a --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/ysod.controller.js @@ -0,0 +1,22 @@ +/** + * @ngdoc controller + * @name Umbraco.Dialogs.LegacyDeleteController + * @function + * + * @description + * The controller for deleting content + */ +function YsodController($scope, legacyResource, treeService, navigationService) { + + if ($scope.error && $scope.error.data && $scope.error.data.StackTrace) { + //trim whitespace + $scope.error.data.StackTrace = $scope.error.data.StackTrace.trim(); + } + + $scope.closeDialog = function() { + $scope.dismiss(); + }; + +} + +angular.module("umbraco").controller("Umbraco.Dialogs.YsodController", YsodController); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/ysod.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/ysod.html new file mode 100644 index 0000000000..2ad93bb30a --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/ysod.html @@ -0,0 +1,28 @@ +
+ {{error.data.StackTrace}}
+ |
+