conjure-python
conjure-python copied to clipboard
Feature: Add an option to generate exceptions for Conjure errors
branch off: https://github.com/palantir/conjure-python/pull/1157
For issue: https://github.com/palantir/conjure-python/issues/910
After this PR
A few things happening:
- Threading through a CLI option for generating the errors.
- Core generation logic.
- Used Claude Code to generate the tests for me.
The resulting error look like:
class product_DatasetNotFound(ConjureHTTPError):
"""Thrown when the requested dataset does not exist
"""
ERROR_CODE = "NOT_FOUND"
ERROR_NAMESPACE = "Datasets"
ERROR_NAME = "DatasetNotFound"
class SafeArgs(TypedDict):
dataset_rid: str
available_datasets: List[str]
def __init__(self, base_error: ConjureHTTPError) -> None:
super().__init__(
status_code=base_error.status_code,
error_code=base_error.error_code,
error_name=base_error.error_name,
error_instance_id=base_error.error_instance_id,
parameters=base_error.parameters
)
self.safe_args: product_DatasetNotFound.SafeArgs = {
'dataset_rid': base_error.parameters['datasetRid'],
'available_datasets': base_error.parameters['availableDatasets']
}
@classmethod
def is_instance(cls, error: ConjureHTTPError) -> bool:
return (
error.error_name == cls.ERROR_NAME and
error.error_code == cls.ERROR_CODE
)
@classmethod
def from_error(cls, error: ConjureHTTPError) -> 'product_DatasetNotFound':
if not cls.is_instance(error):
raise ValueError(f"Error is not a {cls.ERROR_NAME}")
return cls(error)
product_DatasetNotFound.__name__ = "DatasetNotFound"
product_DatasetNotFound.__qualname__ = "DatasetNotFound"
product_DatasetNotFound.__module__ = "package_name.product"
Also placed a follow-up item for using the enum for ErrorCode after https://github.com/palantir/conjure-python-client/pull/171.
✅ Successfully generated changelog entry!
Entry generated via PR title
To modify this entry, edit PR title using proper format.
🔄 Changelog entries were re-generated at Tue, 28 Jul 2026 18:49:46 UTC!
📋Changelog Preview
✨ Features
- Add an option to generate exceptions for Conjure errors (#1306)
Released 4.26.0
This creates a tag and GitHub release. Additional build or deployment steps may still be in progress.