Created
June 29, 2014 02:35
-
-
Save yubessy/43c21eafb58c7bc69bde to your computer and use it in GitHub Desktop.
簡単なエラーメッセージ出力
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# stdlib | |
import sys | |
import traceback | |
def print_exception(func, log_file=sys.stderr): | |
u""" | |
関数実行中に発生した例外を出力 | |
""" | |
def decorated_func(*args, **kwargs): | |
try: | |
func(*args, **kwargs) | |
except Exception: | |
print >> log_file, traceback.format_exc() | |
return decorated_func | |
def print_stderr(message): | |
u""" | |
メッセージを標準エラー出力に書く | |
""" | |
print >> sys.stderr, message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment