python-botogram/botogram

Show exact location on messages' parse errors

Opened this issue · 1 comments

If you send a message with rich formatting, but a parsing error in it, Telegram returns just a cryptic message. Fortunately, there is where the error occured, so botogram should display it in a better way.

For the implementation, I would like to mimic the SyntaxError behavior. After some research, I found you can do that with:

class MyError(Exception):

    def __init__(self):
        # Standard exception attributes
        self.msg = 'abc'

        # Attributes which mimics the SyntaxError behavior
        self.filename = '<message>'
        self.lineno = 1
        self.offset = 3
        self.text = 'hey'
        self.print_file_and_line = None  # The trick to activate everything