Throw actual errors rather than simple strings

This helps downstream, because when errors are later caught the Error object contains a stack trace.