Skip to content
Snippets Groups Projects
Commit 781faa57 authored by inso's avatar inso
Browse files

New error handling

parent b988a348
Branches
Tags
No related merge requests found
......@@ -5,8 +5,10 @@ Created on 1 févr. 2014
"""
import aiohttp
import logging
import traceback
from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, QMessageBox, QLabel, QComboBox, QDialog, QApplication
from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, \
QMessageBox, QLabel, QComboBox, QDialog, QApplication, QErrorMessage
from PyQt5.QtCore import QLocale, QEvent, \
pyqtSlot, QDateTime, QTimer, Qt, QObject, QUrl
from PyQt5.QtGui import QIcon
......@@ -29,6 +31,7 @@ from ..core.community import Community
from ..tools.decorators import asyncify
from ..__init__ import __version__
from .widgets import toast
from .widgets.dialogs import QAsyncMessageBox
class MainWindow(QObject):
......
......@@ -180,6 +180,7 @@ class TransferMoneyDialog(QObject):
@asyncify
async def relative_amount_changed(self, value):
raise Exception("Test")
ud_block = await self.community.get_ud_block()
dividend = ud_block['dividend']
base = ud_block['unitbase']
......
......@@ -12,12 +12,14 @@ import traceback
# To debug missing spec
import jsonschema
import traceback
# To force cx_freeze import
import PyQt5.QtSvg
from quamash import QSelectorEventLoop
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtCore import Qt
from sakia.gui.mainwindow import MainWindow
from sakia.core.app import Application
......@@ -55,13 +57,38 @@ def async_exception_handler(loop, context):
for ignored in ("Unclosed", "socket.gaierror"):
if ignored in line:
return
os._exit(1)
exception_message(log_lines, exc_info)
def exception_handler(*exc_info):
logging.error("An unhandled exception occured",
exc_info=exc_info)
exception_message(["An unhandled exception occured"], exc_info)
def exception_message(log_lines, exc_info):
stacktrace = traceback.format_exception(*exc_info) if exc_info else ""
message = """
{log_lines}
----
{stacktrace}
""".format(log_lines='\n'.join(log_lines), stacktrace='\n'.join(stacktrace))
mb = QMessageBox(QMessageBox.Critical, "Critical error",
"""A critical error occured. Select the details to display it.
Please report it to <a href=\"https://github.com/duniter/sakia/issues/new\">the developers github</a>""",
QMessageBox.Ok, QApplication.activeWindow())
mb.setDetailedText(message)
mb.setTextFormat(Qt.RichText)
mb.setTextInteractionFlags(Qt.TextSelectableByMouse)
mb.exec()
if __name__ == '__main__':
# activate ctrl-c interrupt
signal.signal(signal.SIGINT, signal.SIG_DFL)
sakia = QApplication(sys.argv)
sys.excepthook = exception_handler
sakia.setStyle('Fusion')
loop = QSelectorEventLoop(sakia)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment