Skip to content

Commit af77755

Browse files
committed
Make AlphaVantageError conform to LocalizedError
1 parent 1504344 commit af77755

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/AlphaSwiftage/Public/AlphaVantageError.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@
77

88
import Foundation
99

10-
public enum AlphaVantageError: Error {
10+
public enum AlphaVantageError: Error, LocalizedError {
1111
case apiError(AlphaVantageAPIError)
1212
case unexpectedResponse(String)
1313
case unknown(Error)
14+
15+
public var errorDescription: String? {
16+
switch self {
17+
case .apiError(let apiError):
18+
return apiError.errorDescription
19+
case .unexpectedResponse(let response):
20+
return response
21+
case .unknown(let error):
22+
return error.localizedDescription
23+
}
24+
}
1425
}
1526

1627
public struct AlphaVantageAPIError: Codable, LocalizedError, Equatable {

0 commit comments

Comments
 (0)