mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-15 09:43:34 +01:00
[ToastView]: Fix: restore back to printing localizedDescription as before
This commit is contained in:
@@ -27,7 +27,7 @@ class ErrorProcessing {
|
||||
self.recur = recur
|
||||
}
|
||||
|
||||
private func processError(_ error: NSError, getMoreErrors: (_ error: NSError)->String) -> String{
|
||||
private func processError(_ error: NSError, ignoreTitle: Bool = false, getMoreErrors: (_ error: NSError)->String) -> String{
|
||||
// if unique was requested and if this error is duplicate, ignore processing it
|
||||
let serializedError = "\(error)"
|
||||
if unique && errors.contains(serializedError) {
|
||||
@@ -39,7 +39,7 @@ class ErrorProcessing {
|
||||
var desc = ""
|
||||
switch (info){
|
||||
case .localizedDescription:
|
||||
title = (error.localizedTitle.map{$0+"\n"} ?? "")
|
||||
title = !ignoreTitle ? (error.localizedTitle.map{$0+"\n"} ?? "") : ""
|
||||
desc = error.localizedDescription
|
||||
case .fullError:
|
||||
desc = serializedError
|
||||
@@ -54,13 +54,14 @@ class ErrorProcessing {
|
||||
return getDescriptionText(error: error)
|
||||
}
|
||||
|
||||
private lazy var recurseErrors = { error in
|
||||
self.getDescriptionText(error: error) // recursively process underlying error(s) if any
|
||||
}
|
||||
|
||||
func getDescriptionText(error: NSError) -> String{
|
||||
func getDescriptionText(error: NSError,_ depth: Int = 0) -> String{
|
||||
// closure
|
||||
let recurseErrors = { error in
|
||||
self.getDescriptionText(error: error, depth+1) // recursively process underlying error(s) if any
|
||||
}
|
||||
|
||||
var description = ""
|
||||
|
||||
// process current error only if recur was not requested
|
||||
let processMoreErrors = recur ? recurseErrors : {_ in ""}
|
||||
|
||||
@@ -74,7 +75,9 @@ class ErrorProcessing {
|
||||
let error = underlyingError as NSError
|
||||
description += processError(error, getMoreErrors: processMoreErrors)
|
||||
} else {
|
||||
description += processError(error, getMoreErrors: processMoreErrors)
|
||||
// ignore the title for the base error since we wanted this to be description
|
||||
let isBaseError = (depth == 0)
|
||||
description += processError(error, ignoreTitle: isBaseError, getMoreErrors: processMoreErrors)
|
||||
}
|
||||
return description
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user