Skip to content

Commit

Permalink
fix(service): add proper error if a dataset can't be found (#3661)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Dec 21, 2023
1 parent ec1e282 commit 8afaedd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion renku/ui/service/errors.py
Expand Up @@ -121,7 +121,7 @@ def _handle_sentry(self):
sentry_target = sentry_url.netloc.split("@")[-1]
# NOTE: sentry doesn't support a global search. A proper link would require the specific org
sentry = f"{sentry_url.scheme }://{sentry_target}/organizations/sentry?query={sentry}"
except Exception:
except Exception: # nosec
pass
except KeyError as e:
sentry = f"Unexpected error while reporting to Sentry: {str(e)}"
Expand Down Expand Up @@ -348,6 +348,19 @@ def __init__(self, exception=None):
super().__init__(exception=exception)


class UserDatasetsNotFoundError(ServiceError):
"""Dataset couldn't be found in project."""

code = SVC_ERROR_USER + 133
userMessage = (
"The dataset doesn't exist in the project. Please check your inputs or create the target dataset first."
)
devMessage = "The dataset couldn't be found in the project."

def __init__(self, exception=None):
super().__init__(exception=exception)


class UserOutdatedProjectError(ServiceError):
"""The operation can be done only after updating the target project."""

Expand Down
4 changes: 4 additions & 0 deletions renku/ui/service/views/error_handlers.py
Expand Up @@ -28,6 +28,7 @@
AuthenticationError,
DatasetExistsError,
DatasetImageError,
DatasetNotFound,
DockerfileUpdateError,
GitCommandError,
GitError,
Expand Down Expand Up @@ -65,6 +66,7 @@
ProgramUpdateProjectError,
ServiceError,
UserDatasetsMultipleImagesError,
UserDatasetsNotFoundError,
UserDatasetsUnlinkError,
UserDatasetsUnreachableImageError,
UserInvalidGenericFieldsError,
Expand Down Expand Up @@ -368,6 +370,8 @@ def decorated_function(*args, **kwargs):
if "".join(value) == "Field may not be null.":
raise UserMissingFieldError(e, key)
raise
except DatasetNotFound as e:
raise UserDatasetsNotFoundError(e)
except DatasetExistsError as e:
raise IntermittentDatasetExistsError(e)
except RenkuException as e:
Expand Down

0 comments on commit 8afaedd

Please sign in to comment.