Changeset 9e430d0 in sasmodels


Ignore:
Timestamp:
Mar 26, 2015 2:42:20 PM (10 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
2c801fe
Parents:
f1b8c90
Message:

move exception annotation into its own module

Location:
sasmodels
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    rdb8756e r9e430d0  
    5151from .core import list_models, load_model_definition, load_model, HAVE_OPENCL 
    5252from .core import make_kernel, call_kernel, call_ER, call_VR 
    53  
    54  
    55 def annotate_exception(exc, msg): 
    56     """ 
    57     Add an annotation to the current exception, which can then be forwarded 
    58     to the caller using a bare "raise" statement to reraise the annotated 
    59     exception. 
    60     Example:: 
    61         >>> D = {} 
    62         >>> try: 
    63         ...    print D['hello'] 
    64         ... except Exception,exc: 
    65         ...    annotate_exception(exc, "while accessing 'D'") 
    66         ...    raise 
    67         Traceback (most recent call last): 
    68             ... 
    69         KeyError: "hello while accessing 'D'" 
    70     """ 
    71     args = exc.args 
    72     if not args: 
    73         exc.args = (msg,) 
    74     else: 
    75         try: 
    76             arg0 = " ".join((args[0],msg)) 
    77             exc.args = tuple([arg0] + list(args[1:])) 
    78         except: 
    79             exc.args = (" ".join((str(exc),msg)),) 
     53from .exception import annotate_exception 
    8054 
    8155 
Note: See TracChangeset for help on using the changeset viewer.