Is there any way to hide portions of an exception stack trace? When
users get exceptions when using pyparsing, there are usually many
layers of pyparsing-internal stack messages that are not at all
helpful in diagnosing the problem - the intervening messages just
divert the user's attention from the most significant parts of the
stack, usually the user's call into my module, and the root exception
message. For instance, here is a stack trace:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 1065, in
parseString
loc, tokens = self._parse( instring, 0 )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in
_parseCache
value = self._parseNoCa che( instring, loc, doActions,
callPreParse )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 941, in
_parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 2577, in
parseImpl
return self.expr._pars e( instring, loc, doActions,
callPreParse=Fa lse )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in
_parseCache
value = self._parseNoCa che( instring, loc, doActions,
callPreParse )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 941, in
_parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 2325, in
parseImpl
loc, exprtokens = e._parse( instring, loc, doActions )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in
_parseCache
value = self._parseNoCa che( instring, loc, doActions,
callPreParse )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 941, in
_parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 2577, in
parseImpl
return self.expr._pars e( instring, loc, doActions,
callPreParse=Fa lse )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in
_parseCache
value = self._parseNoCa che( instring, loc, doActions,
callPreParse )
File "/usr/lib/python2.5/site-packages/pyparsing.py", line 943, in
_parseNoCache
raise ParseException( instring, len(instring), self.errmsg, self )
pyparsing.Parse Exception: Expected ")" (at char 82), (line:1, col:83)
The only helpful content here is just this much:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyparsing.Parse Exception: Expected ")" (at char 82), (line:1, col:83)
That is, the point in the program where the user's code called
parseString, and the exception raised deep down in the recursive
parser that determined there was a missing closing paren in the input
string being parsed.
Is there any way for me to suppress these non-value-added API-internal
traceback levels?
-- Paul 3 4350
On Nov 8, 1:25*am, Paul McGuire <pt...@austin.r r.comwrote:
Is there any way for me to suppress these non-value-added API-internal
traceback levels?
Hey Paul,
Have you taken a look at the traceback module?
print_tb(sys.la st_traceback, <limit>) or
extract_tb(sys. last_traceback, limit) could do the trick.
Paul McGuire wrote:
Is there any way to hide portions of an exception stack trace? Â*When
Add a try...except at the appropriate level. Why do you want to do anything
more complex?
Peter
On Nov 7, 10:30*am, Peter Otten <__pete...@web. dewrote:
Paul McGuire wrote:
Is there any way to hide portions of an exception stack trace? *When
Add a try...except at the appropriate level. Why do you want to do anything
more complex?
Peter
I thought I tried that, and now in retrying, I learned a little about
exceptions.
My first attempt was to use this code in the entry method of the API
(parseString):
try:
loc, tokens = self._parse( instring, 0 )
if parseAll:
loc = self.preParse( instring, loc )
StringEnd()._pa rse( instring, loc )
except ParseBaseExcept ion, exc:
raise
else:
return tokens
This didn't change the stack trace at all. But when I change it to
this:
try:
loc, tokens = self._parse( instring, 0 )
if parseAll:
loc = self.preParse( instring, loc )
StringEnd()._pa rse( instring, loc )
except ParseBaseExcept ion, exc:
raise exc
else:
return tokens
Now the stack trace only shows my top-level API method. (I've also
added a little self-explanatory comment as to why I am catching an
exception, just to raise it again.)
Thanks for the nudge in the right direction,
-- Paul This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Linus Nikander |
last post by:
After trying to manually reverse-engineer a piece of code i've been handed
using Visio I figure someone must have developed a tool that can do
automatically in 5 minutes what took me 2 hours.
What I need is a tool that i can tell to "start with this method call, and
show me what happens" . The tool would then go through the sourcecode...
|
by: Mike Schilling |
last post by:
I have some code that calls methods reflectively (the method called and its
parameters are determined by text received in a SOAP message, and I
construct a map from strings to MethodInfos). The code that does the call
looks roughly like:
try
{
// do reflective call
response = method.Invoke(obj, params);
}
|
by: Mark Miller |
last post by:
I just recently started getting the above error on a page I am posting
MULTIPART/FORM-DATA. We have SoftArtisans FileUp component and Filter
installed on the server in question and up until a day or so ago everything
was working fine. I honestly can't remember changing anything since it was
last working. But I tried reinstalling the .Net...
|
by: D A H |
last post by:
I have gotten the same exception in multiple projects.
I have solved the underlying problem.
My question is if anyone knew of a setting that would cause this
exception to be thrown.
A codeveloper on the same project can get a copy of the project from
VSS and does not get this exception, ever. I do. We both have the
code that causes...
|
by: Nirbho |
last post by:
Hi,
I'm newish to C# .Net. I'm doing some error handling in my ASP.net pages.
When handling the error in the catch block, I want to pass through the
namespace of where the error occured.. something like
"application.page.method" - I could hardcode this for every ASP.net page, but
I'm sure there must be something in .Net that gives me this...
| |
by: jf li |
last post by:
I have a Asp.net web application and a Asp.net Web service application. The
Web application is using HtmlInputFile to get a 50M size of file selected by
end user, read the data of this file and pass the data to the web service. I
already modified both web.config files and changed maxRequestLength to
60000(kb). When I debug the upload process,...
|
by: Modica82 |
last post by:
I have created a contract first web service, and to test i have created a
client (asp.net) to attempt to test that my web service is at least
communication. But when i call a method i get the above error for one of my
methods, its not even the one i am calling. Does anyone have an ideas on how
to fix this?
Regards,
Rob
|
by: John K |
last post by:
How do you hide the available functions (and syntax) that are normally
displayed when you browse to a webservice (e.g. httpx://xxx.com/CMgr.asmx)?
If you go to that page you will see a list of the available functions and
you can click on the function name to reveal the calling syntax. We need to
remove this documentation for security...
|
by: barker7 |
last post by:
I am calling an unmanaged C++ method from C#. When an exception occurs
in the C++ code, it gets caught in our C# code.
CSharpMethod()
{
try
{
NativeCPPMethod();
}
catch (Exception e)
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |