Update
[beaver.git] / tensorstack.py
index 584c12d..074588e 100755 (executable)
@@ -11,9 +11,9 @@ import sys
 
 
 def exception_hook(exc_type, exc_value, tb):
-    r"""Hacks the call stack message to show all the local variables in
-    case of RuntimeError or ValueError, and prints tensors as shape,
-    dtype and device.
+    r"""Hacks the call stack message to show all the local variables
+    in case of relevant error, and prints tensors as shape, dtype and
+    device.
 
     """
 
@@ -28,7 +28,7 @@ def exception_hook(exc_type, exc_value, tb):
         print(f'  File "{filename}", line {line_no}, in {name}')
         print(open(filename, "r").readlines()[line_no - 1])
 
-        if exc_type in {RuntimeError, ValueError}:
+        if exc_type in {RuntimeError, ValueError, IndexError}:
             for n, v in tb.tb_frame.f_locals.items():
                 print(f"  {n} -> {v}")