File: excepthook.py

package info (click to toggle)
fontforge 0.0.20120101%2Bgit-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 35,756 kB
  • sloc: ansic: 556,562; sh: 236; makefile: 162; xml: 11; python: 11
file content (19 lines) | stat: -rw-r--r-- 610 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Contributed by Max Rabkin, 2008
# With this installed python exceptions will be reported through the
# fontforge user interface and not to stderr.

import sys
import traceback
import fontforge

def excepthook (*args):
    tb = ''.join(traceback.format_exception(*args))
    message = ''.join(traceback.format_exception_only(*args[:2])).strip()

    fontforge.logWarning(tb.replace('%', '%%'))
    fontforge.postError('Unhandled exception',
                        message.replace('%','%%'))

if fontforge.hasUserInterface():
    # only install the hook if this session has UI
    sys.excepthook = excepthook