properly raise errors to ease debugging