-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Updated agents-api/agents_api/common/excepti
- Loading branch information
1 parent
66cc905
commit 499d1a3
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
"""This module defines custom exceptions related to user operations in the agents-api.""" | ||
|
||
from uuid import UUID | ||
from . import BaseCommonException | ||
|
||
|
||
class BaseUserException(BaseCommonException): | ||
"""Base exception class for user-related errors. This class serves as a parent for all user-related exceptions to facilitate catching errors specific to user operations.""" | ||
pass | ||
|
||
|
||
class UserNotFoundError(BaseUserException): | ||
"""Exception raised when a requested user cannot be found. | ||
Attributes: | ||
developer_id (UUID | str): The ID of the developer attempting the operation. | ||
user_id (UUID | str): The ID of the user that was not found. | ||
""" | ||
def __init__(self, developer_id: UUID | str, user_id: UUID | str): | ||
# Construct an error message indicating the user and developer involved in the error. | ||
super().__init__( | ||
f"User {str(user_id)} not found for developer {str(developer_id)}", | ||
http_code=404, | ||
) | ||
|
||
|
||
class UserDocNotFoundError(BaseUserException): | ||
"""Exception raised when a specific document related to a user cannot be found. | ||
Attributes: | ||
user_id (UUID | str): The ID of the user associated with the document. | ||
doc_id (UUID | str): The ID of the document that was not found. | ||
""" | ||
def __init__(self, user_id: UUID | str, doc_id: UUID | str): | ||
# Construct an error message indicating the document and user involved in the error. | ||
super().__init__( | ||
f"Doc {str(doc_id)} not found for user {str(user_id)}", http_code=404 | ||
) |