I'm using the parse_declaration_list function from tinycss2 which parses css. When I give it invalid css it returns [< ParseError invalid>]. However, I can't for the life of me figure out how to actually catch this error.
I've tried:
try:
parse_declaration_list(arg)
except:
do_something()
no dice.
try:
parse_declaration_list(arg)[0]
except:
do_something()
nope.
try:
parse_declaration_list(arg)
except ParseError:
do_something()
still nothing
error = parse_declaration_list(arg)[0]
if isinstance(error, Exception):
do_something()
Sorry, no can do. I'm completely stumped and everything I google comes up with stuff about normal, well behaved errors.