Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to read and understand errors from tracebacks?

By
ton123
on 4/4/13, 10:29 AM 9,251 views

For me as a non programmer it is difficult to understand what a trace back is trying to tell me.

Does anybody has some tricks for reading?

4

Martin

--Martin--
1978
| 5 6 8
Cornwall, Canada
--Martin--

Analysing, designing, coding and mentoring since 1975. Kilobytes to terabytes. Punch cards to punchy sites. My OpenERP video series: http://www.youtube.com/playlist?list=PLq7op4J183lX44ZlXPiHxUpRvmmRDtxye My Google Speadsheets --> OpenERP Data Pump project: http://martinhbramwell.github.io/GData_OpenERP_Data_Pump My email (with spaces removed) : mhb . warehouseman @ gmail . com

Martin
On 4/4/13, 11:25 AM
  1. Remember that timing errors between browser and server can cause a lot of exceptions to be thrown, typically the really weird ones. Don't dig too far into a traceback until you've confirmed that it is repeatable in FireFox &/or Chrome &/or Explorer.

  2. Read the traceback from bottom to top. The last two or three lines are all you need to know in most cases.

  3. Get a general understanding of how Python generates exception messages in the first place: http://docs.python.org/2/tutorial/errors.html

  4. Get to know the standard Python exceptions and their meanings. http://docs.python.org/2/library/exceptions.html#bltin-exceptions

  5. Get to know the standard OpenERP exceptions and their meanings. http://bazaar.launchpad.net/~openerp/openobject-server/7.0/view/head:/openerp/exceptions.py

  6. Learn to recognize OpenERP directory names. When you see them in a traceback, especially the ones near the bottom of the traceback, they'll help you get an idea of the general circumstances of the exception.

  7. Usually, tracebacks pinpoint the exact line of an exception with perfect accuracy. Cut'n paste the directory and file name of the last line in the traceback into the {File} >> {Open} dialog of your favorite editor, then go to the indicated line. Study the meaning of the exception. Is it a Python standard exception? Is it an OpenERP standard exception? Did the module developer invent his own? Read the docs of the exception. Try to get an idea of what the code was trying to do. Often an exception is thrown within an if statement; understand what the if condition condition was. For example if (idx > max) : could throw a LookupError. What was being indexed? What was the maximum expected?

  8. Repeat the preceding for the next line up in the traceback. That'll show you the place from which the problem function was called, and will help a lot with getting an idea of what the code was trying to do. For one reason or another it passed garbage to the function that threw the error. Why did it do it?

Don't be afraid of code! Check out this Q & A. https://accounts.openerp.com/forum/Help-1/question/8344?answer=8380#post-id-8380. As you can see AttributeError: 'NoneType' object has no attribute 'search' is just a really unfriendly way of describing a really simple fault.

If you do ask for help, have mercy on the community, DO format the traceback properly. This . . .

Client Traceback (most recent call last):

File "/var/packages/OpenERP6.1/target/openerp/addons/web/common/http.py", 
  line 180, in dispatch response["result"] = method(controller, self, **self.params)

File "/var/packages/OpenERP6.1/target/openerp/addons/web/controllers/main.py",
  line 316, in translations for x in po:

File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/messages/catalog.py", 
  line 522, in __iter__ 

File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/messages/catalog.py", 
  line 302, in _get_mime_headers

File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/dates.py", 
  line 501, in format_datetime

File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/core.py", 
  line 212, in parse

File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/core.py",
  line 137, in __init__ UnknownLocaleError: unknown locale 'en'

. . . is a hell of a lot easier to read than this . . .

Client Traceback (most recent call last): File "/var/packages/OpenERP6.1/target/openerp/addons/web/common/http.py", line 180, in dispatch response["result"] = method(controller, self, **self.params) File "/var/packages/OpenERP6.1/target/openerp/addons/web/controllers/main.py", line 316, in translations for x in po: File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/messages/catalog.py", line 522, in __iter__ File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/messages/catalog.py", line 302, in _get_mime_headers File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/dates.py", line 501, in format_datetime File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/core.py", line 212, in parse File "/volume1/@appstore/Python/usr/lib/python2.7/site-packages/babel/core.py", line 137, in __init__ UnknownLocaleError: unknown locale 'en'

wouldn't it be nice if this site had a traceback formatting option!

Martin
on 4/4/13, 11:45 AM

I think this is both helpful for a non programmer / python specialist like me as also for more technical guy's. Thank you, I learn a lot.

ton123
on 4/4/13, 3:55 PM
1
Lorenzo Cabrini
On 4/4/13, 10:48 AM

Not strictly related to OpenERP, but nonetheless:

Either become a programmer or forget about it and just provide full stacktraces for developers to look at. May I suggest that the first alternative is a good one? Programming is fun, can be rewarding (and not just financially) and Python is not very hard to learn.

In the meantime, if you get a long stacktrace with many chained errors, you need to try to identify the source error. Usually, look at the bottom of the trace. The message will give you the type of error, the module and the line number that caused the problem. Open up the file in $EDITOR and start looking. Usually this involves keeping a track of what different variables contain line by line.

You will need to get familiar with different error types. Some are provided by Python, such as syntax errors, type errors and value errors. Others are provided by various modules for their own purposes (for example an email parsing module could provide an InvalidEmailError for its own purposes). Searching the 'Net for something like "python valueerror" may be useful to get more information on a particular error type.

This is also helpful for a non programmer / python specialist. Maybe better answers will come. But for me this is at this moment ok. Thank you. Sorry Lorenzo Cabrini you was good, but for me Martin H. Bramwell answer is better.

ton123
on 4/4/13, 10:56 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/4/13, 10:29 AM
Seen: 9251 times
Last updated: 3/16/15, 8:10 AM