Added more common exceptions

This commit is contained in:
Programmer-0-0 2023-08-27 15:20:28 +04:00
parent dde2f42138
commit eb725bf4a1
2 changed files with 68 additions and 2 deletions

View file

@ -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"
}
}

View file

@ -949,6 +949,35 @@
<!-- Common exceptions -->
<!-- Do not translate "WebView" -->
<string name="exception_http">HTTP %d, check website in WebView</string>
<string name="exception_offline">No Internet connection</string>
<string name="exception_offline">No internet connection</string>
<string name="exception_unknown_host">Couldn\'t reach %s</string>
<string name="exception_socket_error">Socket error</string>
<string name="exception_connect">Failed to connect to host</string>
<string name="exception_bind_port">Failed to bind to the port</string>
<string name="exception_io_interrupted">IO operation interrupted</string>
<string name="exception_http_retry">HTTP operation needs to retry</string>
<string name="exception_port_unreachable">Port unreachable</string>
<string name="exception_io_error">IO error occurred</string>
<string name="exception_timed_out">Operation timed out</string>
<string name="exception_ssl_connection">SSL connection error</string>
<string name="exception_ssl_certificate">SSL certificate expired</string>
<string name="exception_ssl_not_valid">SSL certificate not yet valid</string>
<string name="exception_ssl_parsing">Error parsing SSL certificate</string>
<string name="exception_ssl_encoding">Error encoding SSL certificate</string>
<string name="exception_unrecoverable_key">Unrecoverable key encountered</string>
<string name="exception_key_management">Issue with key management</string>
<string name="exception_algorithm">Algorithm not available</string>
<string name="exception_keystore">Keystore error</string>
<string name="exception_security_provider">Security provider not found</string>
<string name="exception_signature_validation">Issue with signature validation</string>
<string name="exception_key_specification">Invalid key specification</string>
<string name="exception_route_to_host">No route to host</string>
<string name="exception_uri_syntax">Invalid URI syntax</string>
<string name="exception_malformed_url">Malformed URL</string>
<string name="exception_protocol_proxy_type">Invalid protocol or proxy type</string>
<string name="exception_cancelled">Operation was cancelled</string>
<string name="exception_interrupted">Operation was interrupted</string>
<string name="exception_unexpected_state">Unexpected state encountered</string>
<string name="exception_not_supported">Operation not supported</string>
<string name="exception_invalid_argument">Invalid argument provided</string>
</resources>