replicate the proper internal error-handling

It was trickier than just throwing a random exception.