<!--
{
  "availability" : [
    "Xcode: 16.0.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "swift: 6.0.0 -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/Issue/record(_:_:sourceLocation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift Testing",
      "Testing"
    ],
    "preciseIdentifier" : "s:7Testing5IssueV6record__14sourceLocationACs5Error_p_AA7CommentVSgAA06SourceE0VtFZ"
  },
  "title" : "record(_:_:sourceLocation:)"
}
-->

# record(_:_:sourceLocation:)

Record a new issue when a running test unexpectedly catches an error.

```
@discardableResult static func record(_ error: any Error, _ comment: Comment? = nil, sourceLocation: SourceLocation = #_sourceLocation) -> Issue
```

## Parameters

`error`

The error that caused the issue.

`comment`

A comment describing the expectation.

`sourceLocation`

The source location to which the issue should be
attributed.

## Return Value

The issue that was recorded.

## Discussion

This function can be used if an unexpected error is caught while running a
test and it should be treated as a test failure. If an error is thrown
from a test function, it is automatically recorded as an issue and this
function does not need to be used.

---

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)