mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-01 05:48:22 +03:00
ErrorInfo will now remove duplicate Throwables
this helps prevent the TransactionTooLargeException that happens when trying to report a crash
This commit is contained in:
parent
5a65a7a07d
commit
dee69e4ae8
2 changed files with 19 additions and 4 deletions
|
@ -68,17 +68,32 @@ class ErrorInfo(
|
|||
|
||||
// constructors with list of throwables
|
||||
constructor(throwable: List<Throwable>, userAction: UserAction, request: String) :
|
||||
this(throwable, userAction, SERVICE_NONE, request)
|
||||
this(removeDuplicates(throwable.toMutableList()), userAction, SERVICE_NONE, request)
|
||||
constructor(throwable: List<Throwable>, userAction: UserAction, request: String, serviceId: Int) :
|
||||
this(throwable, userAction, ServiceHelper.getNameOfServiceById(serviceId), request)
|
||||
this(removeDuplicates(throwable.toMutableList()), userAction, ServiceHelper.getNameOfServiceById(serviceId), request)
|
||||
constructor(throwable: List<Throwable>, userAction: UserAction, request: String, info: Info?) :
|
||||
this(throwable, userAction, getInfoServiceName(info), request)
|
||||
this(removeDuplicates(throwable.toMutableList()), userAction, getInfoServiceName(info), request)
|
||||
|
||||
companion object {
|
||||
const val SERVICE_NONE = "none"
|
||||
|
||||
fun throwableToStringList(throwable: Throwable) = arrayOf(throwable.stackTraceToString())
|
||||
|
||||
fun removeDuplicates(items: MutableList<Throwable>): List<Throwable> {
|
||||
val messageCache = HashSet<String?>()
|
||||
val iterator = items.listIterator()
|
||||
while (iterator.hasNext()) {
|
||||
val item = iterator.next()
|
||||
val message = item.message
|
||||
if (messageCache.contains(message)) {
|
||||
iterator.remove()
|
||||
} else {
|
||||
messageCache.add(message)
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
fun throwableListToStringList(throwableList: List<Throwable>) =
|
||||
throwableList.map { it.stackTraceToString() }.toTypedArray()
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInf
|
|||
errors.removeIf(ContentNotSupportedException.class::isInstance);
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
dynamicallyShowErrorPanelOrSnackbar(new ErrorInfo(result.getErrors(),
|
||||
dynamicallyShowErrorPanelOrSnackbar(new ErrorInfo(errors,
|
||||
errorUserAction, "Start loading: " + url, serviceId));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue