Skip to content

Commit 627e82e

Browse files
committed
Sensible error message for unknown MetaEvent types
1 parent 42e8ec4 commit 627e82e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

midi.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,10 @@ def _parse(cls, source):
986986
"""Delegate parser method. Called by Event.parse."""
987987
if cls == MetaEvent:
988988
type = next(source)
989-
return cls._events[type]._parse(source)
989+
try:
990+
return cls._events[type]._parse(source)
991+
except KeyError:
992+
raise MIDIError('Unknown Meta Event type: {0:X}.'.format(type))
990993
else:
991994
length = _var_int_parse(source)
992995
data = bytearray()

0 commit comments

Comments
 (0)