improved error messages

This commit is contained in:
leminlimez
2024-11-11 13:00:31 -05:00
parent 22e569f193
commit c2bacd2995

View File

@@ -16,14 +16,29 @@ from tweaks.custom_gestalt_tweaks import CustomGestaltTweaks
from tweaks.basic_plist_locations import FileLocationsList
from Sparserestore.restore import restore_files, FileToRestore
def show_error_msg(txt: str):
def show_error_msg(txt: str, detailed_txt: str = None):
detailsBox = QMessageBox()
detailsBox.setIcon(QMessageBox.Critical)
detailsBox.setWindowTitle("Error!")
detailsBox.setText(txt)
detailsBox.setDetailedText(str(traceback.format_exc()))
if detailed_txt != None:
detailsBox.setDetailedText(detailed_txt)
detailsBox.exec()
def show_apply_error(e: Exception, update_label=lambda x: None):
if "Find My" in str(e):
show_error_msg("Find My must be disabled in order to use this tool.",
detailed_txt="Disable Find My from Settings (Settings -> [Your Name] -> Find My) and then try again.")
elif "SessionInactive" in str(e):
show_error_msg("The session was terminated. Refresh the device list and try again.")
elif "Password" in str(e):
show_error_msg("Device is password protected! You must trust the computer on your device.",
detailed_txt="Unlock your device. On the popup, click \"Trust\", enter your password, then try again.")
else:
show_error_msg(type(e).__name__ + ": " + repr(e), detailed_txt=str(traceback.format_exc()))
print(traceback.format_exc())
update_label("Failed to restore")
class DeviceManager:
## Class Functions
def __init__(self):
@@ -50,7 +65,7 @@ class DeviceManager:
If you are on Windows, make sure you have the \"Apple Devices\" app from the Microsoft Store or iTunes from Apple's website.
If you are on Linux, make sure you have usbmuxd and libimobiledevice installed.
"""
""", detailed_txt=str(traceback.format_exc())
)
self.set_current_device(index=None)
return
@@ -99,7 +114,7 @@ class DeviceManager:
self.devices.append(dev)
except Exception as e:
print(f"ERROR with lockdown device with UUID {device.serial}")
show_error_msg(type(e).__name__ + ": " + repr(e))
show_error_msg(type(e).__name__ + ": " + repr(e), detailed_txt=str(traceback.format_exc()))
connected_devices.remove(device)
else:
connected_devices.remove(device)
@@ -342,23 +357,7 @@ class DeviceManager:
QMessageBox.information(None, "Success!", "All done! " + msg)
update_label("Success!")
except Exception as e:
if "Find My" in str(e):
detailsBox = QMessageBox()
detailsBox.setIcon(QMessageBox.Critical)
detailsBox.setWindowTitle("Error!")
detailsBox.setText("Find My must be disabled in order to use this tool.")
detailsBox.setDetailedText("Disable Find My from Settings (Settings -> [Your Name] -> Find My) and then try again.")
detailsBox.exec()
elif "SessionInactive" in str(e):
detailsBox = QMessageBox()
detailsBox.setIcon(QMessageBox.Critical)
detailsBox.setWindowTitle("Error!")
detailsBox.setText("The session was terminated. Refresh the device list and try again.")
detailsBox.exec()
else:
print(traceback.format_exc())
update_label("Failed to restore")
show_error_msg(type(e).__name__ + ": " + repr(e))
show_apply_error(e, update_label)
## RESETTING MOBILE GESTALT
def reset_mobilegestalt(self, settings: QSettings, update_label=lambda x: None):
@@ -381,14 +380,4 @@ class DeviceManager:
QMessageBox.information(None, "Success!", "All done! " + msg)
update_label("Success!")
except Exception as e:
if "Find My" in str(e):
detailsBox = QMessageBox()
detailsBox.setIcon(QMessageBox.Critical)
detailsBox.setWindowTitle("Error!")
detailsBox.setText("Find My must be disabled in order to use this tool.")
detailsBox.setDetailedText("Disable Find My from Settings (Settings -> [Your Name] -> Find My) and then try again.")
detailsBox.exec()
else:
print(traceback.format_exc())
update_label("Failed to restore")
show_error_msg(type(e).__name__ + ": " + repr(e))
show_apply_error(e)