turning CrashReporter on and off

Please share your functions/code-snips

turning CrashReporter on and off

Postby udo.killermann » Fri Jul 30, 2010 6:07 am

Board,

sometimes it can get really annoying that the Crash Reporter (see below) shows up after your application just failed you and exit with an exception. The Crash Reporter looks like this (at least on my German OSX):
crashReporter.jpg
crash reporter in action
crashReporter.jpg (34.12 KiB) Viewed 31 times


I just press [ignore] every time, but I don't want to be alerted in the first place.

Here is a class (UKCrashReporter.NSObject) I constructed as a helper to disable Crash Reporter in some situations:
Code: Select all
Dim crashReporter As Boolean

Dim reportNone As Array
Dim reportCrash As Array

Function crashReporter() As Boolean
  Return crashReporter 
End Function

Sub setCrashReporter(state As Boolean)
  crashReporter = state
 
  If (crashReporter) Then
    Run("/usr/bin/defaults", reportCrash)
Else
    Run("/usr/bin/defaults",reportNone)
  End If
End Sub

Sub setcrashReporter(state As Boolean)
  setCrashReporter(state)
End Sub 
 
Event Init()
  reportNone = Array("write", "com.apple.CrashReporter","DialogType","none")
  reportCrash = Array("write", "com.apple.CrashReporter", "DialogType", "crashreport")
End Event

Crash Reporter is controlled via user defaults and I could have used NSUserDefaults but the command line just comes in handy.

The methods are thought to work at the class level and should be used this way:
Code: Select all
' Global Object:
' this method isn't there at all - just demo
Declare Function "NSString" + (void)helloWorld

Dim myArrRead As Array
Dim myArrWrite As Array

Event AwakeFromNib()
  UKCrashReporter.crashReporter = No
 
  ' do something wrong
  NSString.helloWorld()
 
End Event


Give it a try and comment back to me.

Regards
Udo
Regards
Udo

--------------
MacBook (2GHz, 4 GByte) - Snow Leopard (10.6.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 105
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: turning CrashReporter on and off

Postby berndnoetscher » Mon Aug 02, 2010 10:12 am

Thanks. Could be integrated into the IDE as a preference.
berndnoetscher
Site Admin
 
Posts: 142
Joined: Fri Feb 20, 2009 11:58 am


Return to Code examples

Who is online

Users browsing this forum: No registered users and 1 guest

cron