From 325da35a82a4c0d013cc72917dba4955c5ab6109 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Tue, 23 Jul 2024 18:19:05 -0600 Subject: [PATCH] Make the error messages readable (#370) * make the error messages readable * Update tests.yml * Update tests.yml * add an install for rust * Update tests.yml * another ci try --- .github/workflows/tests.yml | 4 ++-- Sources/XMTPiOS/Client.swift | 14 ++++++++++++-- dev/up | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 77997eaf..ba5aeb98 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,7 +22,7 @@ jobs: - name: Checkout project sources uses: actions/checkout@v3 - + # This step and the Install Colima step have been modified to address a # Python error started 3.11.2024, emitting the following error: # @@ -77,4 +77,4 @@ jobs: run: script/run_tests.sh - name: Stop local test server - run: docker-compose -p xmtp-ios -f dev/local/docker-compose.yml down \ No newline at end of file + run: docker-compose -p xmtp-ios -f dev/local/docker-compose.yml down diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index 3aa6c565..9b892066 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -11,7 +11,7 @@ import web3 public typealias PreEventCallback = () async throws -> Void -public enum ClientError: Error, CustomStringConvertible { +public enum ClientError: Error, CustomStringConvertible, LocalizedError { case creationError(String) case noV3Client(String) @@ -23,6 +23,10 @@ public enum ClientError: Error, CustomStringConvertible { return "ClientError.noV3Client: \(err)" } } + + public var errorDescription: String? { + return description + } } /// Specify configuration options for creating a ``Client``. @@ -128,7 +132,13 @@ public final class Client { ) return try await create(account: account, apiClient: apiClient, options: options) } catch { - throw ClientError.creationError("\(error)") + let detailedErrorMessage: String + if let nsError = error as NSError? { + detailedErrorMessage = nsError.description + } else { + detailedErrorMessage = error.localizedDescription + } + throw ClientError.creationError(detailedErrorMessage) } } diff --git a/dev/up b/dev/up index 49ea0deb..4bd01ae7 100755 --- a/dev/up +++ b/dev/up @@ -11,6 +11,10 @@ if [[ "${OSTYPE}" == "darwin"* ]]; then /Library/Java/JavaVirtualMachines/ fi if ! kotlinc -version &>/dev/null; then brew install kotlin; fi + if ! which rustup &>/dev/null; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source $HOME/.cargo/env + fi fi rustup update