Skip to content

Commit 5b0c84a

Browse files
committed
Error codes for unexpected inputs
1 parent 12beb94 commit 5b0c84a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

adafruit_display_shapes/rect.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def __init__(
6262
self._bitmap = displayio.Bitmap(width, height, 2)
6363
self._palette = displayio.Palette(2)
6464

65+
if width <= 0 or height <= 0:
66+
raise ValueError("Width and height must be greater than 0")
67+
6568
if outline is not None:
6669
self._palette[1] = outline
6770
for w in range(width):

adafruit_display_shapes/roundrect.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def __init__(
6868
y_offset=height - 2 * r - 1,
6969
)
7070

71+
if width <= 0 or height <= 0:
72+
raise ValueError("Width and height must be greater than 0")
73+
7174
if fill is not None:
7275
self._palette[2] = fill
7376
self._palette.make_opaque(2)

0 commit comments

Comments
 (0)