From eb725bf4a1b79130ca9ebb541712989d2eb4f450 Mon Sep 17 00:00:00 2001 From: Programmer-0-0 Date: Sun, 27 Aug 2023 15:20:28 +0400 Subject: [PATCH] Added more common exceptions --- .../presentation/util/ExceptionFormatter.kt | 39 ++++++++++++++++++- i18n/src/main/res/values/strings.xml | 31 ++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt b/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt index 9b4d4286f3..0caa1f76a8 100644 --- a/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt +++ b/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt @@ -27,7 +27,44 @@ val Throwable.formattedMessage: String is LicensedMangaChaptersException -> return getString(R.string.licensed_manga_chapters_error) } return when (val className = this::class.simpleName) { - "Exception", "IOException" -> message ?: className + "Exception" -> message ?: className + // General networking exceptions + "SocketException" -> getString(R.string.exception_socket_error) + "ConnectException" -> getString(R.string.exception_connect) + "BindException" -> getString(R.string.exception_bind_port) + "InterruptedIOException" -> getString(R.string.exception_io_interrupted) + "HttpRetryException" -> getString(R.string.exception_http_retry) + "PortUnreachableException" -> getString(R.string.exception_port_unreachable) + // General IO-related exceptions + "IOException" -> if (isOnline()) getString(R.string.exception_io_error) else getString(R.string.exception_offline) + "TimeoutException" -> getString(R.string.exception_timed_out) + // SSL & Security-related + "SSLException" -> getString(R.string.exception_ssl_connection) + "CertificateExpiredException" -> getString(R.string.exception_ssl_certificate) + "CertificateNotYetValidException" -> getString(R.string.exception_ssl_not_valid) + "CertificateParsingException" -> getString(R.string.exception_ssl_parsing) + "CertificateEncodingException" -> getString(R.string.exception_ssl_encoding) + "UnrecoverableKeyException" -> getString(R.string.exception_unrecoverable_key) + "KeyManagementException" -> getString(R.string.exception_key_management) + "NoSuchAlgorithmException" -> getString(R.string.exception_algorithm) + "KeyStoreException" -> getString(R.string.exception_keystore) + "NoSuchProviderException" -> getString(R.string.exception_security_provider) + "SignatureException" -> getString(R.string.exception_signature_validation) + "InvalidKeySpecException" -> getString(R.string.exception_key_specification) + // Host & DNS-related + "NoRouteToHostException" -> getString(R.string.exception_route_to_host) + // URL & URI related + "URISyntaxException" -> getString(R.string.exception_uri_syntax) + "MalformedURLException" -> getString(R.string.exception_malformed_url) + // Authentication & Proxy + "ProtocolException" -> getString(R.string.exception_protocol_proxy_type) + // Concurrency & Operation-related + "CancellationException" -> getString(R.string.exception_cancelled) + "InterruptedException" -> getString(R.string.exception_interrupted) + "IllegalStateException" -> getString(R.string.exception_unexpected_state) + "UnsupportedOperationException" -> getString(R.string.exception_not_supported) + "IllegalArgumentException" -> getString(R.string.exception_invalid_argument) + else -> "$className: $message" } } diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index bf7c33bb26..82959bd0a1 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -949,6 +949,35 @@ HTTP %d, check website in WebView - No Internet connection + No internet connection Couldn\'t reach %s + Socket error + Failed to connect to host + Failed to bind to the port + IO operation interrupted + HTTP operation needs to retry + Port unreachable + IO error occurred + Operation timed out + SSL connection error + SSL certificate expired + SSL certificate not yet valid + Error parsing SSL certificate + Error encoding SSL certificate + Unrecoverable key encountered + Issue with key management + Algorithm not available + Keystore error + Security provider not found + Issue with signature validation + Invalid key specification + No route to host + Invalid URI syntax + Malformed URL + Invalid protocol or proxy type + Operation was cancelled + Operation was interrupted + Unexpected state encountered + Operation not supported + Invalid argument provided