-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
raise를 이용하여 Error를 발생시킬경우 as를 통해 Error가 발생한 부분을 출력 할 수 없는건가요?
21.08.24 16:36 작성 조회수 192
1
항상 친절한 답변 감사합니다
답변을 작성해보세요.
1
좋은사람
지식공유자2021.08.24
def demo_bad_catch():
try:
raise ValueError('Represents a hidden bug, do not catch this')
raise Exception('This is the exception you expect to handle')
except Exception as error:
print('Caught this error: ' + repr(error))
>>> demo_bad_catch()
Caught this error: ValueError('Represents a hidden bug, do not catch this',)
위에 소스를 한 번 보세요~ 출력 가능합니다. Value 에러가 먼저 잡히겠죠?
답변 1