create error wrapper and an unwrap function