7

So I'm stepping through a script using PDB and it raises an exception, but for some reason it abbreviates the exception to the point that it is unreadable. How do I get it to print the whole exception? Can I get a reference to the exception? I would think this would be a built-in command, such as "rv".

Nick Retallack
  • 18,986
  • 17
  • 92
  • 114
  • possible duplicate of [Get last exception in pdb](http://stackoverflow.com/questions/19211034/get-last-exception-in-pdb) – shx2 Apr 11 '14 at 05:25
  • 1
    This is not a duplicate. If you trigger an exception while in pdb those answers will not help. – Marcin Jul 29 '15 at 02:01
  • If you're triggering it directly you can just use the "except Except as e" in the setup (where e is some arbitrary var you make up) and then look at e afterwards. Not sure if this fits your use case (since it seems too obvious) – Alex North-Keys Aug 08 '16 at 06:49
  • Workaround: Try copying the failing line and pasting it to pdb cli, something like: ex= x/0 - now u have the exception stored in ex, it is a workaround, but it works – Ohad the Lad Jul 27 '17 at 05:49
  • Exceptions don't work that way. You'd have to catch it somehow, but I'm not sure you can. – Nick Retallack Feb 27 '18 at 07:46

1 Answers1

0

I think, it can help:

try:
    **your code**
except Exception as e:
    print(e)