<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Scripting Bridge",
  "identifier" : "/documentation/ScriptingBridge/SBApplicationDelegate/eventDidFail(_:withError:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Scripting Bridge"
    ],
    "preciseIdentifier" : "c:objc(pl)SBApplicationDelegate(im)eventDidFail:withError:"
  },
  "title" : "eventDidFail(_:withError:)"
}
-->

# eventDidFail(_:withError:)

Sent by an `SBApplication` object when a target application returns an error
Apple event.

```
func eventDidFail(_ event: UnsafePointer<AppleEvent>, withError error: any Error) -> Any?
```

## Parameters

`event`

A pointer to the Apple event sent to the target application causing
the error.

`error`

An object containing information about the error Apple event.
Specific information may be included in the `useInfo` dictionary of the
error object. The following table shows the possible
keys for this dictionary.
    
    |Key                 |Description                                                                                                                                    |
    |--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
    |ErrorBriefMessage   |A short human-readable description of the error, as an <doc://com.apple.documentation/documentation/Foundation/NSString>                       |
    |ErrorExpectedType   |The type of data the target application expected, as an <doc://com.apple.documentation/documentation/Foundation/NSAppleEventDescriptor> object.|
    |ErrorOffendingObject|The object that caused the error.                                                                                                              |
    |ErrorString         |A full human-readable description of the error, as an <doc://com.apple.documentation/documentation/Foundation/NSString> object.               |
    |ErrorNumber         |The Apple event error number, as an <doc://com.apple.documentation/documentation/Foundation/NSNumber> object.                                  |

## Return Value

If you return a result, it will become the result of the
<doc://com.apple.documentation/documentation/AppKit/NSApplication/sendEvent(_:)>
that failed. Can be `nil`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)