Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-3454] iOS - Display proper error messages for Sargon errors #168

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import SargonUniFFI

public typealias SargonError = CommonError
Expand All @@ -15,3 +16,9 @@ extension SargonError: CustomStringConvertible {
errorMessage
}
}

extension SargonError: LocalizedError {
public var errorDescription: String? {
"\(errorMessage)\nCode: \(errorCode)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we conclude that we wanted to show errorMessage, it is very much a "programmer error" written by me... I think Matt would prefer to not show it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we could use something similar to what Matias suggested. I'll check with Matt.

}
}
5 changes: 5 additions & 0 deletions apple/Tests/TestCases/Prelude/SargonErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ final class SargonErrorTests: Test<SargonError> {
let sut = SUT.UnknownNetworkForId(badValue: 99)
XCTAssertEqual(sut.debugDescription, "10049: No network found with id: '99'")
}

func test_localized_description() {
let sut = SUT.UnknownNetworkForId(badValue: 99)
XCTAssertEqual(sut.localizedDescription, "No network found with id: '99'\nCode: 10049")
}
}
Loading