Added an error message and crash to avoid silent segfaults