Python Forum
How to capture an error message
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to capture an error message
#2
try/except is the proper way to go, example:

import sys


try:
    print('2'+2)
except TypeError:
    print(f"Caught a TypeError exception")
    sys.exit(0)
I added an exit, but you can remove it if you want to analyse the code further.
However, never leave errors in code you plan to release.
Reply


Messages In This Thread
How to capture an error message - by TheHacker707 - Feb-14-2020, 01:00 AM
RE: How to capture an error message - by Larz60+ - Feb-14-2020, 02:39 AM
RE: How to capture an error message - by ibreeden - Feb-15-2020, 11:26 AM
RE: How to capture an error message - by snippsat - Feb-15-2020, 03:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error message about iid from RandomizedSearchCV Visiting 2 1,079 Aug-17-2023, 07:53 PM
Last Post: Visiting
  Another Error message. the_jl_zone 2 1,020 Mar-06-2023, 10:23 PM
Last Post: the_jl_zone
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,444 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Screen capture opencv - grab error Kalman15 1 1,677 Jan-27-2022, 12:22 PM
Last Post: buran
  understanding error message krlosbatist 1 1,948 Oct-24-2021, 08:34 PM
Last Post: Gribouillis
  Error message pybits 1 48,504 May-29-2021, 10:26 AM
Last Post: snippsat
  f-string error message not understood Skaperen 4 3,408 Mar-16-2021, 07:59 PM
Last Post: Skaperen
  Overwhelmed with error message using pandas drop() EmmaRaponi 1 2,416 Feb-18-2021, 07:31 PM
Last Post: buran
  Winning/Losing Message Error in Text based Game kdr87 2 3,053 Dec-14-2020, 12:25 AM
Last Post: bowlofred
  Don't understand error message Milfredo 2 2,095 Aug-24-2020, 05:00 PM
Last Post: Milfredo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020