You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many of `CodableCSV`'s imperative functions may throw errors due to invalid configuration values, invalid CSV input, file stream failures, etc. All these throwing operations exclusively throw `CSVError`s that can be easily caught with `do`-`catch` clause.
268
+
269
+
```swift
270
+
do {
271
+
let writer =tryCSVWriter()
272
+
for row in customData {
273
+
try writer.write(row: row)
274
+
}
275
+
} catchleterror {
276
+
print(error)
277
+
}
278
+
```
279
+
280
+
`CSVError` adopts [Swift Evolution's SE-112](https://github.com/apple/swift-evolution/blob/master/proposals/0112-nserror-bridging.md) protocols (`LocalizedError` and `CustomNSError`) and `CustomDebugStringConvertible`. The error's properties provide rich commentary explaining what went wrong and giving indication on how to fix the problem.
281
+
282
+
- `type`: The error group category.
283
+
- `failureReason`: Explanation on what went wrong.
284
+
- `helpAnchor`: Advice on how to solve the problem.
285
+
- `errorUserInfo`: Arguments associated with the operation that threw the error.
286
+
- `underlyingError`:Optional underlying error, which provoked the operation to fail (most of the time is `nil`).
287
+
- `localizedDescription`: Returns a human readable string with all the information contained in the error.
288
+
289
+
You can get all the information by simply printing the error or calling the `localizedDescription` property on a properly casted `CSVError<CSVReader>` or `CSVError<CSVWriter>`.
290
+
259
291
</p></details>
260
292
</ul>
261
293
@@ -481,7 +513,7 @@ struct Student: Codable {
481
513
482
514
</details>
483
515
484
-
<details><summary>Configuration values and encoding/decoding strategies.</summary><p>
0 commit comments