🐛 notify about errors in config.py

This commit is contained in:
Nate Sesti 2023-11-06 17:24:22 -08:00
parent 0871f64503
commit 1235e22e5c
5 changed files with 17 additions and 11 deletions

View file

@ -176,11 +176,7 @@ class ContinueConfig(BaseModel):
convertConfigImports(shorten=True)
return ContinueConfig.from_filepath(filepath, retry=False)
else:
logger.critical(f"Failed to load config.py: {e}")
except Exception as e:
logger.critical(f"Failed to load config.py: {e}")
return ContinueConfig()
raise e
@staticmethod
def load_default() -> "ContinueConfig":

View file

@ -88,7 +88,7 @@ class ProxyServer(LLM):
{
"error_title": "Proxy server stream_chat parsing failed",
"error_message": "\n".join(
traceback.format_exception(e)
traceback.format_exception(e, e, e.__traceback__)
),
},
)

View file

@ -58,7 +58,11 @@ app.add_middleware(
# region: Base endpoints
root_config = ContinueConfig.load_default()
try:
root_config = ContinueConfig.load_default()
except Exception as e:
logger.error(f"Failed to load config.py: {e}")
root_config = ContinueConfig()
@app.get("/slash_commands")

View file

@ -245,7 +245,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
).output
def on_error(self, e: Exception) -> Coroutine:
err_msg = "\n".join(traceback.format_exception(e))
err_msg = "\n".join(traceback.format_exception(e, e, e.__traceback__))
e_title = e.__str__() or e.__repr__()
return self.showMessage(f"Error in Continue server: {e_title}\n {err_msg}")

View file

@ -40,8 +40,10 @@ class Window:
try:
return ContinueConfig.load_default()
except Exception as e:
logger.error(f"Failed to load config.py: {traceback.format_exception(e)}")
self._error_loading_config = e
self._error_loading_config = "\n".join(
traceback.format_exception(e, e, e.__traceback__)
)
logger.error(f"Failed to load config.py: {self._error_loading_config}")
return (
ContinueConfig()
@ -81,7 +83,7 @@ class Window:
):
# Need a non-step way of sending a notification to the GUI. Fine to be displayed similarly
# formatted_err = "\n".join(traceback.format_exception(e))
# formatted_err = "\n".join(traceback.format_exception(e, e, e.__traceback__))
# msg_step = MessageStep(
# name="Invalid Continue Config File", message=formatted_err
# )
@ -92,6 +94,10 @@ class Window:
if self._error_loading_config is not None:
await self.ide.setFileOpen(getConfigFilePath())
await self.ide.showMessage(
f"""We found an error while loading your config.py. For now, Continue is falling back to the default configuration. If you need help solving this error, please reach out to us on Discord by clicking the question mark button in the bottom right.\n\n{self._error_loading_config}"""
)
self._error_loading_config = None
async def index():
async for progress in build_index(self.ide, self.config):