Skip to content

Instantly share code, notes, and snippets.

@yubessy
Created June 29, 2014 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yubessy/43c21eafb58c7bc69bde to your computer and use it in GitHub Desktop.
Save yubessy/43c21eafb58c7bc69bde to your computer and use it in GitHub Desktop.
簡単なエラーメッセージ出力
# -*- 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