Cast error instead of throwing exception