Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: do not log stack traces for HttpException (#235)
This improves on #224. My first attempt dumps the stack for any HttpException, which means any explicit 400, etc, that we raise. What we really want is the stack trace for unexpected errors, that is, anything that isn't HttpException. * Move the stack dump to the base Exception handler * Log `e.detail` in the HttpException handler. This is also important - we want to see what the user ran into. * Disable the `uvicorn.error` logger, which also dumps stack on any exception. We want that to go through our handler. To test, use the curl commands from the last pr. The HttpException (filetype not supported error) should cleanly show as a one liner: ``` 2023-09-15 12:06:13,570 unstructured_api ERROR Unable to process logger_config.yaml: File type None is not supported. 2023-09-15 12:06:13,570 127.0.0.1:58003 POST /general/v0/general HTTP/1.1 - 400 Bad Request ``` The 500 error should show this one liner along with *a single* instance of the stack: ``` File "/Users/austin/repos/pipeline-api/prepline_general/api/general.py", line 386, in pipeline_api raise e File "/Users/austin/repos/pipeline-api/prepline_general/api/general.py", line 367, in pipeline_api elements = partition( File "/Users/austin/.pyenv/versions/pipeline-api/lib/python3.10/site-packages/unstructured/partition/auto.py", line 348, in partition raise ValueError( ValueError: Detected a JSON file that does not conform to the Unstructured schema. partition_json currently only processes serialized Unstructured output. 2023-09-15 12:00:09,585 unstructured_api ERROR Detected a JSON file that does not conform to the Unstructured schema. partition_json currently only processes serialized Unstructured output. 2023-09-15 12:00:09,585 127.0.0.1:57735 POST /general/v0/general HTTP/1.1 - 500 Internal Server Error ```
- Loading branch information