Skip to content

Instantly share code, notes, and snippets.

@Kento75
Last active June 10, 2018 06:22
Show Gist options
  • Save Kento75/3ce46a77ed183bb30d92bfa9af33f47b to your computer and use it in GitHub Desktop.
Save Kento75/3ce46a77ed183bb30d92bfa9af33f47b to your computer and use it in GitHub Desktop.
【Pythonメモ 】例外を呼び出し元に送信する方法 ref: https://qiita.com/Kento75/items/b0f43943d300d0ed9586
#!/usr/bin/python
# -*- Coding: utf-8 -*-
class Hoge(object):
def huga():
try:
raise TypeError('TYPE ERROR!')
except Exception as e:
print(type(e)) # 1回目のエラー出力
raise # 呼び出し元に再送
try:
huga()
except Exception as e:
print(type(e)) # 2回目のエラー出力
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment