Skip to content
Snippets Groups Projects
Commit b7f0e501 authored by dx's avatar dx
Browse files

yeah sure whatever man

parent a354e5ee
No related branches found
No related tags found
1 merge request!651st3m/application: way nicer error display on BundleLoadException
Pipeline #12653 passed
......@@ -71,7 +71,9 @@ class Application(BaseView):
class BundleLoadException(BaseException):
MSG = "failed to load"
def __init__(self, msg: Optional[str] = None, orig_exc: Optional[Exception] = None) -> None:
def __init__(
self, msg: Optional[str] = None, orig_exc: Optional[Exception] = None
) -> None:
res = self.MSG
if msg is not None:
res += ": " + msg
......@@ -293,9 +295,9 @@ class LoadErrorView(BaseView):
direction = ins.buttons.app
if direction == ins.buttons.PRESSED_LEFT or ins.captouch.petals[0].pressed:
self.scroll_pos = max(0, self.scroll_pos - delta_ms/100)
self.scroll_pos = max(0, self.scroll_pos - delta_ms / 100)
elif direction == ins.buttons.PRESSED_RIGHT or ins.captouch.petals[5].pressed:
self.scroll_pos = min(self.scroll_max, self.scroll_pos + delta_ms/100)
self.scroll_pos = min(self.scroll_max, self.scroll_pos + delta_ms / 100)
def draw(self, ctx: Context) -> None:
ctx.rgb(0.8, 0.1, 0.1)
......@@ -321,7 +323,7 @@ class LoadErrorView(BaseView):
view_end = min(len(self.lines), view_start + self.max_lines)
print(view_start, view_end, self.scroll_pos)
for line in self.lines[view_start : view_end]:
for line in self.lines[view_start:view_end]:
ctx.move_to(-100, y)
ctx.text(" ".join(line))
y += 15
......@@ -336,11 +338,11 @@ class LoadErrorView(BaseView):
animation = 10 - animation
if view_end < len(self.lines):
ctx.move_to(0, 120 - animation/2)
ctx.move_to(0, 120 - animation / 2)
ctx.text("\ue5db")
if view_start > 0:
ctx.move_to(0, -105 + animation/2)
ctx.move_to(0, -105 + animation / 2)
ctx.text("\ue5d8")
......@@ -367,7 +369,7 @@ class MenuItemAppLaunch(MenuItem):
self._instance = self._bundle.load()
except BundleLoadException as e:
log.error(f"Could not load {self.label()}: {e}")
if getattr(e, 'orig_exc'):
if getattr(e, "orig_exc"):
e = e.orig_exc
sys.print_exception(e)
err = LoadErrorView(e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment