Skip to content

Commit

Permalink
add more documentation for user
Browse files Browse the repository at this point in the history
  • Loading branch information
InnocentBug committed Feb 28, 2024
1 parent ea8c833 commit 7aa8b30
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cript/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class CRIPTAPIRequiredError(CRIPTException):
"""
## Definition
Exception to be raised when the API object is requested, but no cript.API object exists yet.
Also make sure to use it in a context manager `with cript.API as api:` or manually call
`connect` and `disconnect`.
The CRIPT Python SDK relies on a cript.API object for creation, validation, and modification of nodes.
The cript.API object may be explicitly called by the user to perform operations to the API, or
Expand All @@ -83,14 +85,21 @@ class CRIPTAPIRequiredError(CRIPTException):
my_token = "123456" # To use your token securely, please consider using environment variables
my_api = cript.API(host=my_host, token=my_token)
my_api.connect()
# Your code
my_api.disconnect()
```
"""

def __init__(self):
pass

def __str__(self) -> str:
error_message = "cript.API object is required for an operation, but it does not exist." "Please instantiate a cript.API object to continue." "See the documentation for more details."
error_message = (
"cript.API object is required for an operation, but it does not exist."
"Please instantiate a cript.API object and connect it to API for example with a context manager `with cript.API() as api:` to continue."
"See the documentation for more details."
)

return error_message

Expand Down

0 comments on commit 7aa8b30

Please sign in to comment.