<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSObjectMakeError(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@F@JSObjectMakeError"
  },
  "title" : "JSObjectMakeError(_:_:_:_:)"
}
-->

# JSObjectMakeError(_:_:_:_:)

Creates a JavaScript error object as though invoking the built-in error constructor.

```
func JSObjectMakeError(_ ctx: JSContextRef!, _ argumentCount: Int, _ arguments: UnsafePointer<JSValueRef?>!, _ exception: UnsafeMutablePointer<JSValueRef?>!) -> JSObjectRef!
```

## Parameters

`ctx`

The execution context to use.

`argumentCount`

An integer count of the number of arguments in `arguments`.

`arguments`

A [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) array of arguments to pass to the `Error` constructor. Pass `NULL` if `argumentCount` is `0`.

`exception`

A pointer to a [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) to store an exception in, if any. Pass `NULL` to discard any exception.

## Return Value

A [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) that is an error.

## Discussion

---

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)