Remove ConnectionDetails.error
This commit is contained in:
parent
00a16f454b
commit
ed9ce05282
4 changed files with 8 additions and 10 deletions
|
|
@ -78,12 +78,11 @@ enum class ConnectionState {
|
|||
*/
|
||||
data class ConnectionDetails(
|
||||
val state: ConnectionState = ConnectionState.NOT_APPLICABLE,
|
||||
val error: String? = null,
|
||||
val throwable: Throwable? = null,
|
||||
val error: Throwable? = null,
|
||||
val nextRetryTime: Long = 0L
|
||||
) {
|
||||
fun getStackTraceString(): String {
|
||||
return throwable?.stackTraceToString() ?: ""
|
||||
return error?.stackTraceToString() ?: ""
|
||||
}
|
||||
|
||||
fun hasError(): Boolean {
|
||||
|
|
|
|||
|
|
@ -546,8 +546,8 @@ class Repository(private val sharedPrefs: SharedPreferences, database: Database)
|
|||
)
|
||||
}
|
||||
|
||||
fun updateConnectionDetails(baseUrl: String, state: ConnectionState, error: String? = null, throwable: Throwable? = null, nextRetryTime: Long = 0L) {
|
||||
val details = ConnectionDetails(state, error, throwable, nextRetryTime)
|
||||
fun updateConnectionDetails(baseUrl: String, state: ConnectionState, error: Throwable? = null, nextRetryTime: Long = 0L) {
|
||||
val details = ConnectionDetails(state, error, nextRetryTime)
|
||||
val current = connectionDetails[baseUrl]
|
||||
if (current != details) {
|
||||
if (state == ConnectionState.NOT_APPLICABLE && error == null) {
|
||||
|
|
@ -556,7 +556,7 @@ class Repository(private val sharedPrefs: SharedPreferences, database: Database)
|
|||
connectionDetails[baseUrl] = details
|
||||
}
|
||||
connectionDetailsLiveData.postValue(connectionDetails.toMap())
|
||||
Log.d(TAG, "Connection details updated for $baseUrl: state=$state, error=$error, nextRetry=$nextRetryTime")
|
||||
Log.d(TAG, "Connection details updated for $baseUrl: state=$state, error=${error?.message}, nextRetry=$nextRetryTime")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -309,8 +309,7 @@ class SubscriberService : Service() {
|
|||
val subscriptionId = subscriptionIds.firstOrNull() ?: return
|
||||
val subscription = repository.getSubscription(subscriptionId) ?: return
|
||||
val baseUrl = subscription.baseUrl
|
||||
val errorMessage = throwable?.message
|
||||
repository.updateConnectionDetails(baseUrl, state, errorMessage, throwable, nextRetryTime)
|
||||
repository.updateConnectionDetails(baseUrl, state, throwable, nextRetryTime)
|
||||
}
|
||||
|
||||
private fun onNotificationReceived(subscription: Subscription, notification: io.heckel.ntfy.db.Notification) {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class ConnectionErrorFragment : DialogFragment() {
|
|||
private fun updateErrorDisplay() {
|
||||
val details = selectedBaseUrl?.let { connectionDetails[it] }
|
||||
if (details != null && details.hasError()) {
|
||||
errorTextView.text = details.error
|
||||
errorTextView.text = details.error?.message ?: getString(R.string.connection_error_dialog_no_error)
|
||||
stackTraceTextView.text = details.getStackTraceString().ifEmpty {
|
||||
getString(R.string.connection_error_dialog_no_stack_trace)
|
||||
}
|
||||
|
|
@ -202,7 +202,7 @@ class ConnectionErrorFragment : DialogFragment() {
|
|||
val details = connectionDetails[baseUrl] ?: return
|
||||
val text = buildString {
|
||||
appendLine("Server: $baseUrl")
|
||||
appendLine("Error: ${details.error}")
|
||||
appendLine("Error: ${details.error?.message ?: "Unknown error"}")
|
||||
appendLine()
|
||||
appendLine("Stack trace:")
|
||||
append(details.getStackTraceString().ifEmpty { "No stack trace available" })
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue