Archived Support Site

This support site is archived. You can view the old support discussions but you cannot post new discussions.

Error Handling Code seems to be ignored

skilesare's Avatar

skilesare

13 Feb, 2011 12:21 PM

I have the following code that executes fine in my dev environment but seems to be ignored or errors out in production:

global.asax

    protected void Application_Error(object sender, EventArgs e)
    {
        try
        {
            LinqToColloqDataContext db = DataAccess.GetMWContext();

            Log newLog = new Log();
            System.Exception Thisex = Server.GetLastError();

            newLog.Date = DateTime.UtcNow;
            newLog.Exception = Thisex.ToString() + Thisex.StackTrace.ToString();
            newLog.Level = "1";
            newLog.Message = Thisex.Message;
            newLog.Thread = "x";
            newLog.Logger = "L";

            db.Logs.InsertOnSubmit(newLog);

            db.SubmitChanges();
        }
        catch (System.Exception ex)
        {
            int whattodonow = 1;
        }
    }

I don't know if it is not being hit because appharbor's config intercepts the call before it is called or if it is failing when I try to submit the linq query.

Not having any sort of access to event logs is getting really frustrating.

  1. Support Staff 1 Posted by friism on 13 Feb, 2011 09:21 PM

    friism's Avatar

    Are you using MVC 3? By default, there's an filters.Add(new HandleErrorAttribute()); in the RegisterGlobalFilters method of your Global.asax.cs. If you remove that, your logging-method should be triggered.

    Let me know if this doesn't resolve your problem.

  2. friism closed this discussion on 13 Feb, 2011 09:21 PM.

  3. skilesare re-opened this discussion on 14 Feb, 2011 01:33 AM

  4. 2 Posted by skilesare on 14 Feb, 2011 01:33 AM

    skilesare's Avatar

    Actually, with mvc2 I had to add the custom error mode = off to my web.config. I guess it was using whatever you all have in the machine . Config file.

  5. Support Staff 3 Posted by friism on 14 Feb, 2011 01:47 AM

    friism's Avatar

    OK, that would do it too.

  6. friism closed this discussion on 14 Feb, 2011 01:47 AM.

Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac