mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
fix exception printing bug for directly-raised custom exceptions
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
"""Custom exceptions for hyperglass."""
|
"""Custom exceptions for hyperglass."""
|
||||||
|
|
||||||
# Standard Library
|
# Standard Library
|
||||||
|
import sys
|
||||||
import json as _json
|
import json as _json
|
||||||
from typing import Dict, List, Union, Optional, Sequence
|
from typing import Dict, List, Union, Optional, Sequence
|
||||||
|
|
||||||
@ -46,6 +47,10 @@ class HyperglassError(Exception):
|
|||||||
else:
|
else:
|
||||||
log.info(repr(self))
|
log.info(repr(self))
|
||||||
|
|
||||||
|
if all(sys.exc_info()):
|
||||||
|
# Rich will raise a ValueError if print_exception() is used
|
||||||
|
# outside of a try/except block. Only use Rich for traceback
|
||||||
|
# printing if the exception is caught.
|
||||||
console.print_exception(extra_lines=6)
|
console.print_exception(extra_lines=6)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
Reference in New Issue
Block a user