arcuru / chaz

Chaz is for chats
https://chaz.is
MIT License
35 stars 3 forks source link

Error handling, code style, and using notices for command responses #7

Closed lboklin closed 3 months ago

lboklin commented 3 months ago

Notices are specifically intended for uses such as automated messages, so I made it send notices whenever the reply is not generated by the LLM.

Because AIChat is not properly using exit codes to indicate that something went wrong, I added a check for empty outputs. I would submit a fix to AIChat directly, but after repeated attempts at contributing to that project I've decided against wasting my time on that.

The misc refactors are more opinionated, but there are several reasons to prefer match over early returns:

I couldn't think of a good way to replace the break 'outer with a more functional approach due to the intricacies of borrow handling and the convoluted logic involved, so I gave up on that one.

lboklin commented 3 months ago

I think I understand why you would use error! over info!, though. There is some serious info spam from matrix_sdk that can only be silenced by setting the log level to error. What I do if I need to debug is to use println! instead. I wish I knew of a way to selectively silence such outputs.