API: Fix error reporting
Make a disconnect on load error consistently. It should be safer to warn the user to run unload (or re-run load) if a model does not load correctly. Also don't log the traceback for request errors that don't have one. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
165cc6fc2d
commit
0b25c208d6
2 changed files with 12 additions and 5 deletions
|
|
@ -27,7 +27,7 @@ class TabbyRequestError(BaseModel):
|
|||
error: TabbyRequestErrorMessage
|
||||
|
||||
|
||||
def get_generator_error(message: str):
|
||||
def get_generator_error(message: str, exc_info: bool = True):
|
||||
"""Get a generator error."""
|
||||
|
||||
generator_error = handle_request_error(message)
|
||||
|
|
@ -35,7 +35,7 @@ def get_generator_error(message: str):
|
|||
return get_sse_packet(generator_error.model_dump_json())
|
||||
|
||||
|
||||
def handle_request_error(message: str):
|
||||
def handle_request_error(message: str, exc_info: bool = True):
|
||||
"""Log a request error to the console."""
|
||||
|
||||
error_message = TabbyRequestErrorMessage(
|
||||
|
|
@ -45,7 +45,7 @@ def handle_request_error(message: str):
|
|||
request_error = TabbyRequestError(error=error_message)
|
||||
|
||||
# Log the error and provided message to the console
|
||||
if error_message.trace:
|
||||
if error_message.trace and exc_info:
|
||||
logger.error(error_message.trace)
|
||||
|
||||
logger.error(f"Sent to request: {message}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue