Skip to content

Commit

Permalink
Don't crash when failing to decrypt messages
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Jan 22, 2024
1 parent b98729d commit 2f9ff10
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion heymans/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
import re
from pathlib import Path
from cryptography.fernet import InvalidToken
from .model import model
from . import prompt, config, utils, attachments
from langchain.schema import HumanMessage, AIMessage, SystemMessage
Expand Down Expand Up @@ -198,7 +199,13 @@ def _update_title(self):
self._conversation_title = self._conversation_title[:100] + '…'

def load(self):
conversation = self._heymans.database.get_active_conversation()
try:
conversation = self._heymans.database.get_active_conversation()
except InvalidToken as e:
self.init_conversation()
self.save()
logger.error(f'failed to get active conversation: {e}')
return
if not conversation['message_history']:
self.init_conversation()
return
Expand Down

0 comments on commit 2f9ff10

Please sign in to comment.