Zack Burt
Zack Burt

Reputation: 8455

Show generic error message to users, but send detailed stack trace etc. to admin?

I recently came across this message when trying to do something on my production website:

Server Error in '/' Application.

You must supply either a card or a customer id

Description: 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.

Exception Details: Stripe.StripeException: You must supply either a card or a customer id

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[StripeException: You must supply either a card or a customer id]
Stripe.Requestor.ExecuteWebRequest(WebRequest webRequest) +238
Stripe.Requestor.PostString(String url) +22
Stripe.StripeChargeService.Create(StripeChargeCreateOptions createOptions) +40
AwesomenessWeb.Controllers.CustomersController.PaymentPost(PurchaseType purchaseType, Int32 optionID, String stripeToken) in c:\a\src\AwesomenessWeb\AwesomenessWeb\Controllers\CustomersController.cs:599 lambda_method(Closure , ControllerBase , Object[] ) +193
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +214
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +27
System.Web.Mvc.<>c_DisplayClass15.b_12() +55 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList
1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8
1.b__7(IAsyncResult ) +10 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.<>c_DisplayClasse.b_d() +48
System.Web.Mvc.SecurityUtil.b
_0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9631764 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.19064

Is there any way all of this information can be emailed to my email address.. and a generic page will be displayed to the user?

Upvotes: 0

Views: 892

Answers (1)

RyanR
RyanR

Reputation: 7758

Install ELMAH. It is easy to configure it to show a generic error message to your users, but log and/or email you every detail available on the exception.

Upvotes: 3

Related Questions