Throw correct exception type