Skip to main content

Handling error

Sometimes, the application is making great use of error handling and wants to document these errors, or has some definitive points where caught errors could use a bit more context.

Shake SDK enables you to report the caught errors and lets you decide how they are grouped. These non-fatal error reports will have all of the same contextual information as crash reports, and act as an extension to the crash reporting feature.


Avoid using unique values for error clusterID as this will cause a large number of reported errors appear unrelated โ€” although they actually are โ€” which will clog your Shake dashboard.

override func viewDidLoad() {
do {
try functionThatCanThrowError()
} catch let error {
Shake.handleError(error, clusterID: "MyViewController")
private func functionThatCanThrowError() throws {
throw MyError.testError

Error structure

The handleErrorfunction will accept NSError types which naturally contain the following properties:

  • code: Int
  • domain: String
  • userInfo: [AnyHashable : Any]? = nil

Caught Exceptions?

Shake doesn't provide an interface to directly report caught NSExceptions. Cocoa APIs are not exception safe, and should be treated as a developer error which terminates the program shortly after. Although the NSException can be caught by using the @catch statement, this is considered a bad practice and really shouldn't be done anywhere in your code.