Skip to content

Commit 8afaedd

Browse files
authored
fix(service): add proper error if a dataset can't be found (#3661)
1 parent ec1e282 commit 8afaedd

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

renku/ui/service/errors.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _handle_sentry(self):
121121
sentry_target = sentry_url.netloc.split("@")[-1]
122122
# NOTE: sentry doesn't support a global search. A proper link would require the specific org
123123
sentry = f"{sentry_url.scheme }://{sentry_target}/organizations/sentry?query={sentry}"
124-
except Exception:
124+
except Exception: # nosec
125125
pass
126126
except KeyError as e:
127127
sentry = f"Unexpected error while reporting to Sentry: {str(e)}"
@@ -348,6 +348,19 @@ def __init__(self, exception=None):
348348
super().__init__(exception=exception)
349349

350350

351+
class UserDatasetsNotFoundError(ServiceError):
352+
"""Dataset couldn't be found in project."""
353+
354+
code = SVC_ERROR_USER + 133
355+
userMessage = (
356+
"The dataset doesn't exist in the project. Please check your inputs or create the target dataset first."
357+
)
358+
devMessage = "The dataset couldn't be found in the project."
359+
360+
def __init__(self, exception=None):
361+
super().__init__(exception=exception)
362+
363+
351364
class UserOutdatedProjectError(ServiceError):
352365
"""The operation can be done only after updating the target project."""
353366

renku/ui/service/views/error_handlers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
AuthenticationError,
2929
DatasetExistsError,
3030
DatasetImageError,
31+
DatasetNotFound,
3132
DockerfileUpdateError,
3233
GitCommandError,
3334
GitError,
@@ -65,6 +66,7 @@
6566
ProgramUpdateProjectError,
6667
ServiceError,
6768
UserDatasetsMultipleImagesError,
69+
UserDatasetsNotFoundError,
6870
UserDatasetsUnlinkError,
6971
UserDatasetsUnreachableImageError,
7072
UserInvalidGenericFieldsError,
@@ -368,6 +370,8 @@ def decorated_function(*args, **kwargs):
368370
if "".join(value) == "Field may not be null.":
369371
raise UserMissingFieldError(e, key)
370372
raise
373+
except DatasetNotFound as e:
374+
raise UserDatasetsNotFoundError(e)
371375
except DatasetExistsError as e:
372376
raise IntermittentDatasetExistsError(e)
373377
except RenkuException as e:

0 commit comments

Comments
 (0)