multiplatform: better errors (#4463)

This commit is contained in:
spaced4ndy
2024-07-16 17:19:58 +04:00
committed by GitHub
parent 4251762553
commit 065d9be614
2 changed files with 7 additions and 6 deletions

View File

@@ -1837,17 +1837,17 @@ object ChatController {
r is CR.ChatCmdError && r.chatError is ChatError.ChatErrorAgent
&& r.chatError.agentError is AgentErrorType.SMP
&& r.chatError.agentError.smpErr is SMPErrorType.PROXY ->
proxyErrorAlert(r.chatError.agentError.smpErr.proxyErr)
proxyErrorAlert(r.chatError.agentError.smpErr.proxyErr, r.chatError.agentError.serverAddress)
r is CR.ChatCmdError && r.chatError is ChatError.ChatErrorAgent
&& r.chatError.agentError is AgentErrorType.PROXY
&& r.chatError.agentError.proxyErr is ProxyClientError.ProxyProtocolError
&& r.chatError.agentError.proxyErr.protocolErr is SMPErrorType.PROXY ->
proxyErrorAlert(r.chatError.agentError.proxyErr.protocolErr.proxyErr)
proxyErrorAlert(r.chatError.agentError.proxyErr.protocolErr.proxyErr, r.chatError.agentError.proxyServer)
else -> false
}
}
private fun proxyErrorAlert(pe: ProxyError): Boolean {
private fun proxyErrorAlert(pe: ProxyError, srvAddr: String): Boolean {
return when {
pe is ProxyError.BROKER
&& pe.brokerErr is BrokerErrorType.TIMEOUT -> {
@@ -1876,7 +1876,7 @@ object ChatController {
&& pe.brokerErr is BrokerErrorType.HOST -> {
AlertManager.shared.showAlertMsg(
generalGetString(MR.strings.private_routing_error),
generalGetString(MR.strings.srv_error_host)
String.format(generalGetString(MR.strings.network_error_broker_host_desc), serverHostname(srvAddr))
)
true
}
@@ -1885,7 +1885,7 @@ object ChatController {
&& pe.brokerErr.transportErr is SMPTransportError.Version -> {
AlertManager.shared.showAlertMsg(
generalGetString(MR.strings.private_routing_error),
generalGetString(MR.strings.srv_error_version)
String.format(generalGetString(MR.strings.proxy_error_broker_version_desc), serverHostname(srvAddr))
)
true
}
@@ -5569,7 +5569,7 @@ sealed class AgentErrorType {
}
@Serializable @SerialName("CMD") class CMD(val cmdErr: CommandErrorType): AgentErrorType()
@Serializable @SerialName("CONN") class CONN(val connErr: ConnectionErrorType): AgentErrorType()
@Serializable @SerialName("SMP") class SMP(val smpErr: SMPErrorType): AgentErrorType()
@Serializable @SerialName("SMP") class SMP(val serverAddress: String, val smpErr: SMPErrorType): AgentErrorType()
// @Serializable @SerialName("NTF") class NTF(val ntfErr: SMPErrorType): AgentErrorType()
@Serializable @SerialName("XFTP") class XFTP(val xftpErr: XFTPErrorType): AgentErrorType()
@Serializable @SerialName("PROXY") class PROXY(val proxyServer: String, val relayServer: String, val proxyErr: ProxyClientError): AgentErrorType()

View File

@@ -116,6 +116,7 @@
<string name="network_error_broker_version_desc">Server version is incompatible with your app: %1$s.</string>
<string name="private_routing_error">Private routing error</string>
<string name="please_try_later">Please try later.</string>
<string name="proxy_error_broker_version_desc">Server version is incompatible with network settings: %1$s.</string>
<string name="error_sending_message">Error sending message</string>
<string name="error_creating_message">Error creating message</string>
<string name="error_loading_details">Error loading details</string>