---
title: "error(_:file:line:)"
framework: swift-package-manager
role: symbol
role_heading: Type Method
path: "swift-package-manager/documentation/packageplugin/diagnostics/error(_:file:line:)"
---

# error(_:file:line:)

Emits an error with the message you specify.

## Declaration

```swift
static func error(_ message: String, file: String? = #file, line: Int? = #line)
```

## Parameters

- `message`: The description of the error.
- `file`: The file responsible for the diagnostic, that defaults to #file.
- `line`: The line responsible for the diagnostic, that defaults to #line.

## See Also

### Emitting Errors and Diagnostics

- [progress(_:)](swift-package-manager/documentation/packageplugin/diagnostics/progress(_:).md)
- [warning(_:file:line:)](swift-package-manager/documentation/packageplugin/diagnostics/warning(_:file:line:).md)
- [remark(_:file:line:)](swift-package-manager/documentation/packageplugin/diagnostics/remark(_:file:line:).md)
- [emit(_:_:file:line:)](swift-package-manager/documentation/packageplugin/diagnostics/emit(_:_:file:line:).md)
- [Diagnostics.Severity](swift-package-manager/documentation/packageplugin/diagnostics/severity.md)
