mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Show exception class in snackbar message (#9006)
* Show exception class in snackbar message * omit IOException too
This commit is contained in:
		@@ -225,8 +225,7 @@ class MangaInfoScreenModel(
 | 
			
		||||
 | 
			
		||||
            logcat(LogPriority.ERROR, e)
 | 
			
		||||
            coroutineScope.launch {
 | 
			
		||||
                val errorMessage = e.message.orEmpty().ifEmpty { e.toString() }
 | 
			
		||||
                snackbarHostState.showSnackbar(message = errorMessage)
 | 
			
		||||
                snackbarHostState.showSnackbar(message = e.snackbarMessage)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -516,7 +515,7 @@ class MangaInfoScreenModel(
 | 
			
		||||
                context.getString(R.string.no_chapters_error)
 | 
			
		||||
            } else {
 | 
			
		||||
                logcat(LogPriority.ERROR, e)
 | 
			
		||||
                e.message.orEmpty().ifEmpty { e.toString() }
 | 
			
		||||
                e.snackbarMessage
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            coroutineScope.launch {
 | 
			
		||||
@@ -1056,3 +1055,10 @@ val chapterDecimalFormat = DecimalFormat(
 | 
			
		||||
    DecimalFormatSymbols()
 | 
			
		||||
        .apply { decimalSeparator = '.' },
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
private val Throwable.snackbarMessage: String
 | 
			
		||||
    get() = when (val className = this::class.simpleName) {
 | 
			
		||||
        null -> message ?: ""
 | 
			
		||||
        "Exception", "HttpException", "IOException" -> message ?: className
 | 
			
		||||
        else -> "$className: $message"
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user