Assert the right error will be returned