added handling of cast errors to httperror class; added HttpError.catch method