title: How do I execute first my custom error message before the first Traceback?
body: <p>I made a program with restrictions with Tkinter and I created a custom error message wherein if the conditions for the restriction is met, then an error message box would pop up.</p>
  <p>Now, my problem is that the message box only pops up after terminating my program, it doesn't get
  executed while the program is still open, here's my code.</p>
  <pre><code>try:
      None
  
  except:
      raise SyntaxError(messagebox.showerror('Error', 'Error message')
  </code></pre>
  <p>This is the output:</p>
  <blockquote>
  <p>Exception in Tkinter callback Traceback (most recent call last):<br />
  File
  &quot;C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\tkinter_<em>init</em>_.py&quot;,
  line 1921, in <strong>call</strong>
  return self.func(*args)   File &quot;C:\Users\user1\PycharmProjects\Python Program\main.py&quot;, line 53, in
  
  command=lambda: equal(), relief=FLAT, borderwidth=1)   File &quot;C:\Users\user1\PycharmProjects\Python Porgram\main.py&quot;, line 32, in
  equal
  result = str(eval(expression))   File &quot;&quot;, line 1
  */
  ^ SyntaxError: invalid syntax Traceback (most recent call last):   File &quot;C:\Users\user1\PycharmProjects\Python Program\main.py&quot;, line
  171, in 
  raise SyntaxError(messagebox.showerror('Error', 'You cannot bundle two or more operations together.')) SyntaxError: ok</p>
  </blockquote>
  <p>Process finished with exit code 1</p>