Implemented YSOD overlay when an unhandled server exception is thrown, this also ensures only when debug=true in the web.config which is injected into the server vars.
This commit is contained in:
@@ -16,5 +16,6 @@ Umbraco.Sys.ServerVariables = {
|
||||
},
|
||||
umbracoSettings: {
|
||||
"umbracoPath": "/umbraco"
|
||||
}
|
||||
},
|
||||
isDebuggingEnabled: true
|
||||
};
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -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
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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;}
|
||||
@@ -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);
|
||||
@@ -0,0 +1,28 @@
|
||||
<div class="umb-modalcolumn ysod" ng-controller="Umbraco.Dialogs.YsodController">
|
||||
|
||||
<a href="" ng-click="closeDialog()" class="btn">Close</a>
|
||||
|
||||
<h1>{{error.errorMsg}}</h1>
|
||||
<hr />
|
||||
<h2>{{error.data.ExceptionMessage}}</h2>
|
||||
<div>
|
||||
<b>Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
|
||||
<br />
|
||||
<br />
|
||||
<b>Exception Details: </b>{{error.data.ExceptionType}}: {{error.data.ExceptionMessage}}
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<b>Stack Trace:</b>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<pre>{{error.data.StackTrace}}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
@@ -68,7 +68,8 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
{"umbracoPath", GlobalSettings.Path}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "isDebuggingEnabled", HttpContext.IsDebuggingEnabled }
|
||||
};
|
||||
|
||||
return JavaScript(ServerVariablesParser.Parse(d));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
||||
Reference in New Issue
Block a user