Commit 690a26c9 authored by Jim Fulton's avatar Jim Fulton

Brian's changes to try and get file name and line no in exceptions.

parent 16d4c6ca
"""Bobo call interface"""
__version__='$Revision: 1.6 $'[11:-2]
__version__='$Revision: 1.7 $'[11:-2]
import sys,regex
from httplib import HTTP
......@@ -74,12 +74,14 @@ exceptmap ={'AccessError' :AccessError,
class RemoteException:
def __init__(self,etype=None,evalue=None,url=None,query=None,
http_code=None, http_msg=None, http_resp=None):
def __init__(self,etype=None,evalue=None,efile=None,eline=None,url=None,
query=None,http_code=None,http_msg=None, http_resp=None):
"""Contains information about an exception which
occurs in a remote method call"""
self.exc_type =etype
self.exc_value =evalue
self.exc_file =efile
self.exc_line =eline
self.url =url
self.query =query
self.http_code =http_code
......@@ -87,8 +89,9 @@ class RemoteException:
self.response =http_resp
def __repr__(self):
return '%s\n%s %s for %s' % (self.exc_value,self.http_code,
self.http_message,self.url)
return '%s (File: %s Line: %s)\n%s %s for %s' % (
self.exc_value,self.exc_file,self.exc_line,
self.http_code,self.http_message,self.url)
......@@ -151,12 +154,17 @@ class RemoteMethod:
else:
try: v=headers.dict['bobo-exception-value']
except: v=ec
try: f=headers.dict['bobo-exception-file']
except: f='Unknown'
try: l=headers.dict['bobo-exception-line']
except: l='Unknown'
try: t=exceptmap[headers.dict['bobo-exception-type']]
except:
if ec >= 400 and ec < 500: t=NotFound
elif ec >= 500 and ec < 600: t=ServerError
else: t=NotAvailable
raise t, RemoteException(t,v,self.url,query,ec,em,response)
raise t, RemoteException(t,v,f,l,self.url,query,ec,em,response)
......@@ -245,8 +253,8 @@ if __name__ == "__main__": main()
#
# $Log: Client.py,v $
# Revision 1.6 1997/04/18 16:41:36 jim
# Machine name printed in NotFound
# Revision 1.7 1997/04/18 19:45:47 jim
# Brian's changes to try and get file name and line no in exceptions.
#
# Revision 1.5 1997/04/16 21:56:27 jim
# repr now shows URL on Not Found.
......
......@@ -3,7 +3,7 @@
__doc__='''CGI Response Output formatter
$Id: Response.py,v 1.14 1997/04/12 17:17:32 jim Exp $'''
$Id: Response.py,v 1.15 1997/04/18 19:46:19 jim Exp $'''
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
......@@ -55,6 +55,9 @@ $Id: Response.py,v 1.14 1997/04/12 17:17:32 jim Exp $'''
# (540) 371-6909
#
# $Log: Response.py,v $
# Revision 1.15 1997/04/18 19:46:19 jim
# Brian's changes to try and get file name and line no in exceptions.
#
# Revision 1.14 1997/04/12 17:17:32 jim
# Brian added loggic to set bobo-specific headers to transmit exception
# info.
......@@ -119,7 +122,7 @@ $Id: Response.py,v 1.14 1997/04/12 17:17:32 jim Exp $'''
#
#
#
__version__='$Revision: 1.14 $'[11:-2]
__version__='$Revision: 1.15 $'[11:-2]
import string, types, sys, regex, regsub
......@@ -482,9 +485,14 @@ class Response:
# Try to capture exception info for bci calls
et=regsub.gsub('\n','\t\n',str(t))
ev=regsub.gsub('\n','\t\n',str(v))
el=str(tb.tb_lineno)
ef=str(tb.tb_frame.f_code.co_filename)
if string.find(ev,'<html>') >= 0: ev='bobo exception'
self.setHeader('bobo-exception-type',et)
self.setHeader('bobo-exception-value',ev)
self.setHeader('bobo-exception-file',ef)
self.setHeader('bobo-exception-line',el)
except:
# Dont try so hard that we cause other problems ;)
pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment