Skip to content

Commit 6f58497

Browse files
authored
Make MLXError provide a description (#268)
* MLXError provides error message
1 parent b89259d commit 6f58497

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Source/MLX/ErrorHandler.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ public func withError<R>(_ body: () async throws -> R) async throws -> R {
216216
/// Error type for caught errors during ``withError(_:)-6g4wn``.
217217
public enum MLXError: Error {
218218
case caught(String)
219+
220+
var localizedDescription: String {
221+
switch self {
222+
case .caught(let message): "MLX Error: \(message)"
223+
}
224+
}
219225
}
220226

221227
/// Boxed error type usable with ``withError(_:)-2wfiu``.

0 commit comments

Comments
 (0)