Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 an easy way to disable exception handling
#1
while debugging code, often my exception handling obscures what is really going on. i usually have to take the exception handling out. and that is typically a lot of work, especially saving that code or typing it all back in. and, of course, i have to unindent the active code. so what i have done is replace the try: with if 1: and the except: with if 0:. but even that is a fair amount of typing to put it in and undo it. my latest thought is to just change the exception being handled to one that mostly never happens (when my code is trying to run). would SyntaxError be a viable choice (in running code being debugged). the idea is to temporarily be handling an exception that does not happen so that the exception that really does happen is not handled, letting it stop the code and dump the stack.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#2
See here:
https://dev.to/wemake-services/python-ex...ttern-17o9
Quote
#3
too much code being added to support coding. things should ideally be expressed as simple as possible and added on mechanisms should be added after the coding is done,like in the compiling phase.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#4
instead, i went with TabError which doesn't happen for me, anymore.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#5
(Jun-01-2019, 04:10 AM)Skaperen Wrote: often my exception handling obscures what is really going on.

Idea of exception handling is to handle expected exceptions and propagate non-expected as usual. Can you give some examples/hints how exception handling obscures what is really going on?
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Life of Brian: Conjugate the verb, "to go" !
Quote
#6
i'm handle lots of excepts in this case because there are many possible during these function calls.. but while debugging i would rather not handle any and let things dump and come to a screeching halt. but taking out the code is more of a hassle (indent changes) than changing it to handle something i really know won't happen.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#7
Quote:often my exception handling obscures what is really going on.

Far from being an anti-pattern, exceptions are the best friends of the python programmer. They carry all the key information that makes debugging a breeze.

As often as you can, don't handle exceptions. Let them propagate unless it really makes a lot of sense to handle them.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Handling Thick client applications using Python PraveenSubramaniyan 1 119 Jul-22-2019, 01:08 PM
Last Post: DeaD_EyE
  How to fix 'uncaught exception of type NSException' in Python MonsterPython 0 113 Jul-09-2019, 06:52 AM
Last Post: MonsterPython
  problem using custom exception handling in python srm 3 175 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  'Exception Has occured: UnBoundLocalError' caston 1 164 Jun-12-2019, 02:33 PM
Last Post: perfringo
  is there an easy way to add a progress bar/counter to an existing script Soundtechscott 6 559 Jun-09-2019, 06:30 AM
Last Post: snippsat
  exception name for a flagged stop Skaperen 1 521 May-31-2019, 04:33 AM
Last Post: heiner55
  name of exception for exit() Skaperen 2 235 May-24-2019, 07:07 PM
Last Post: Skaperen
  exception handling KyawMyo 3 266 May-07-2019, 07:53 AM
Last Post: buran
  How do i get matplotlib event handling to work? jenya56 3 455 Apr-24-2019, 06:53 PM
Last Post: jenya56
  Handling pound sign (#) within custom URL chisox721 5 428 Apr-02-2019, 10:01 PM
Last Post: chisox721

Forum Jump:


Users browsing this thread: 1 Guest(s)