---
title: "executeAndReturnError(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsapplescript/executeandreturnerror(_:)"
---

# executeAndReturnError(_:)

Executes the receiver, compiling it first if it is not already compiled.

## Declaration

```swift
func executeAndReturnError(_ errorInfo: AutoreleasingUnsafeMutablePointer<NSDictionary?>?) -> NSAppleEventDescriptor
```

## Parameters

- `errorInfo`: On return, if an error occurs, a pointer to an error information dictionary.

## Return Value

Return Value The result of executing the event, or nil if an error occurs.

## Discussion

Discussion Any changes to property values caused by executing the script do not persist.

## See Also

### Compiling and Executing a Script

- [compileAndReturnError(_:)](foundation/nsapplescript/compileandreturnerror(_:).md)
- [executeAppleEvent(_:error:)](foundation/nsapplescript/executeappleevent(_:error:).md)
