Skip to content

Commit 99f2fb8

Browse files
committed
Better feedback when getting window or context before creation
1 parent 4c8901b commit 99f2fb8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

demosys/context/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66

77
def window() -> 'demosys.context.base.Window':
88
"""The window instance we are rendering to"""
9+
if not WINDOW:
10+
raise RuntimeError("Attempting to get window before creation")
11+
912
return WINDOW
1013

1114

1215
def ctx() -> moderngl.Context:
1316
"""ModernGL context"""
14-
return WINDOW.ctx
17+
win = window()
18+
if not win.ctx:
19+
raise RuntimeError("Attempting to get context before creation")
20+
21+
return win.ctx

0 commit comments

Comments
 (0)