foundry_dev_tools.errors.handling module#
Error handling configuration for FoundryAPIErrors.
- foundry_dev_tools.errors.handling.DEFAULT_ERROR_MAPPING: dict[str | None, type[FoundryAPIError]] = {'Catalog:BranchesAlreadyExist': <class 'foundry_dev_tools.errors.dataset.BranchesAlreadyExistError'>, 'Catalog:BranchesNotFound': <class 'foundry_dev_tools.errors.dataset.BranchNotFoundError'>, 'Catalog:DatasetsNotFound': <class 'foundry_dev_tools.errors.dataset.DatasetNotFoundError'>, 'Catalog:DuplicateDatasetName': <class 'foundry_dev_tools.errors.dataset.DatasetAlreadyExistsError'>, 'Catalog:InvalidArgument': <class 'foundry_dev_tools.errors.dataset.DatasetNotFoundError'>, 'Catalog:SimultaneousOpenTransactionsNotAllowed': <class 'foundry_dev_tools.errors.dataset.DatasetHasOpenTransactionError'>, 'Compass:AutosaveResourceOperationForbidden': <class 'foundry_dev_tools.errors.compass.AutosaveResourceOperationForbiddenError'>, 'Compass:CannotMoveResourcesUnderHiddenResource': <class 'foundry_dev_tools.errors.compass.CannotMoveResourcesUnderHiddenResourceError'>, 'Compass:CircularDependency': <class 'foundry_dev_tools.errors.compass.CircularDependencyError'>, 'Compass:DuplicateName': <class 'foundry_dev_tools.errors.compass.DuplicateNameError'>, 'Compass:ForbiddenOperationOnHiddenResource': <class 'foundry_dev_tools.errors.compass.ForbiddenOperationOnHiddenResourceError'>, 'Compass:ForbiddenOperationOnServiceProjectResource': <class 'foundry_dev_tools.errors.compass.ForbiddenOperationOnServiceProjectResourceError'>, 'Compass:GatekeeperInsufficientPermissions': <class 'foundry_dev_tools.errors.compass.GatekeeperInsufficientPermissionsError'>, 'Compass:IllegalName': <class 'foundry_dev_tools.errors.compass.IllegalNameError'>, 'Compass:InsufficientPermissions': <class 'foundry_dev_tools.errors.compass.InsufficientPermissionsError'>, 'Compass:InvalidMarking': <class 'foundry_dev_tools.errors.compass.InvalidMarkingError'>, 'Compass:InvalidMavenGroupPrefix': <class 'foundry_dev_tools.errors.compass.InvalidMavenGroupPrefixError'>, 'Compass:InvalidMavenProductId': <class 'foundry_dev_tools.errors.compass.InvalidMavenProductIdError'>, 'Compass:InvalidOrganizationMarkingHierarchy': <class 'foundry_dev_tools.errors.compass.InvalidOrganizationMarkingHierarchyError'>, 'Compass:MarkingNotFound': <class 'foundry_dev_tools.errors.compass.MarkingNotFoundError'>, 'Compass:MavenProductIdAlreadySet': <class 'foundry_dev_tools.errors.compass.MavenProductIdAlreadySetError'>, 'Compass:MavenProductIdConflict': <class 'foundry_dev_tools.errors.compass.MavenProductIdConflictError'>, 'Compass:MissingOrganizationMarking': <class 'foundry_dev_tools.errors.compass.MissingOrganizationMarkingError'>, 'Compass:NotFound': <class 'foundry_dev_tools.errors.compass.ResourceNotFoundError'>, 'Compass:NotProject': <class 'foundry_dev_tools.errors.compass.NotProjectError'>, 'Compass:OrganizationNotFound': <class 'foundry_dev_tools.errors.compass.OrganizationNotFoundError'>, 'Compass:PathNotFound': <class 'foundry_dev_tools.errors.compass.PathNotFoundError'>, 'Compass:ResourceNotFound': <class 'foundry_dev_tools.errors.compass.ResourceNotFoundError'>, 'Compass:ResourceNotTrashed': <class 'foundry_dev_tools.errors.compass.ResourceNotTrashedError'>, 'Compass:TooManyResourcesRequested': <class 'foundry_dev_tools.errors.compass.TooManyResourcesRequestedError'>, 'Compass:UnexpectedParent': <class 'foundry_dev_tools.errors.compass.UnexpectedParentError'>, 'Compass:UnrecognizedAccessLevel': <class 'foundry_dev_tools.errors.compass.UnrecognizedAccessLevelError'>, 'Compass:UnrecognizedPatchOperation': <class 'foundry_dev_tools.errors.compass.UnrecognizedPatchOperationError'>, 'Compass:UnrecognizedPrincipal': <class 'foundry_dev_tools.errors.compass.UnrecognizedPrincipalError'>, 'Compass:UsersNamespaceOperationForbidden': <class 'foundry_dev_tools.errors.compass.UsersNamespaceOperationForbiddenError'>, 'DataProxy:BadSqlQuery': <class 'foundry_dev_tools.errors.sql.FoundrySqlQueryFailedError'>, 'DataProxy:DatasetNotFound': <class 'foundry_dev_tools.errors.dataset.DatasetNotFoundError'>, 'DataProxy:FallbackBranchesNotSpecifiedInQuery': <class 'foundry_dev_tools.errors.dataset.BranchNotFoundError'>, 'DataProxy:SchemaNotFound': <class 'foundry_dev_tools.errors.dataset.DatasetHasNoSchemaError'>, 'FoundrySqlServer:InvalidDatasetCannotAccess': <class 'foundry_dev_tools.errors.dataset.BranchNotFoundError'>, 'FoundrySqlServer:InvalidDatasetNoSchema': <class 'foundry_dev_tools.errors.dataset.DatasetHasNoSchemaError'>, 'FoundrySqlServer:InvalidDatasetPathNotFound': <class 'foundry_dev_tools.errors.dataset.DatasetNotFoundError'>, 'Multipass:DuplicateGroupName': <class 'foundry_dev_tools.errors.multipass.DuplicateGroupNameError'>, None: <class 'foundry_dev_tools.errors.meta.FoundryAPIError'>}#
This mapping maps the Error names coming from the API to the Foundry DevTools classes.
- class foundry_dev_tools.errors.handling.ErrorHandlingConfig[source]#
Bases:
object
Configuration for foundry error handling.
- Parameters:
api_error_mapping – Either a dictionary which maps either status codes or error names to python Exception classes, or just a python exception class to use it for every HTTP Error. Status codes that are not above 400, which do not raise an HTTP Error, will automatically be raised too
info – additionial information about the error, passed to the constructor of the Exception
kwargs – will be passed to the constructor of the Exception
- __init__(api_error_mapping=None, info=None, **kwargs)[source]#
Configuration for foundry error handling.
- Parameters:
api_error_mapping (dict[str | int, type[FoundryAPIError]] | type[FoundryAPIError] | None) – Either a dictionary which maps either status codes or error names to python Exception classes, or just a python exception class to use it for every HTTP Error. Status codes that are not above 400, which do not raise an HTTP Error, will automatically be raised too
info (str | None) – additionial information about the error, passed to the constructor of the Exception
kwargs – will be passed to the constructor of the Exception
- get_exception_class(response)[source]#
Returns the python exception class for the response.
- Parameters:
response (Response)
- Return type:
type[FoundryAPIError] | None
- get_exception(response)[source]#
Returns exception determined by
ErrorHandlingConfig.get_exception_class()
filled out with the response and kwargs.- Parameters:
response (Response)
- Return type:
FoundryAPIError | None
- foundry_dev_tools.errors.handling.raise_foundry_api_error(response, error_handling=None)[source]#
Raise a foundry API error through the ErrorHandlingConfig.
Convenience function around ErrorHandlingConfig.get_exception.
- Parameters:
response (Response)
error_handling (ErrorHandlingConfig | Literal[False] | None)