Discussion:
[bottlepy] error handling with @error(xx) -- can't get it running!?
'gNeandr' via bottlepy
2017-02-28 20:14:27 UTC
Permalink
With a good working bottle project I try to add an error handler, at best
it should catch all errors and direct to a special page with details what
fails in the module in question.

But also with the very simple example found on https://bottlepy.org/docs/dev/tutorial.html
return 'Nothing here, sorry'
I have no success!
from bottle import route, response, error
I'm expecting that function is called when a unknown page is opened like
this:
http://server:port/xx
192.168.178.26 - - [28/Feb/2017 20:42:20] "GET /xx HTTP/1.1" 404 729
But also syntax error resulting with html error 500 can't be catched.

What has to be checked / changed?
And is there a method to catch all python errors with one routine?
Can someone direct me to right tutorial or so ...
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'gNeandr' via bottlepy
2017-03-02 22:21:16 UTC
Permalink
Ok, one point was wrong with my code.
Because Bottle was called with
app = Bottle()
app.run(..)
@app.error(500)
@app.error(404)
But it doesn't give a general method to catch all html error codes with one
general and customized method/function.

There is a page on stackoverflow with an example contributed by Michael
<http://stackoverflow.com/questions/30854686/how-to-return-error-messages-in-json-with-bottle-httperror/42566998#42566998>,
but there is a point which let me struggle with it, just getting the normal
bottle html error page ... would like to pass/get more python and/or html
error details.
Any help?
With a good working bottle project I try to add an error handler, at best
it should catch all errors and direct to a special page with details what
fails in the module in question.
But also with the very simple example found on
https://bottlepy.org/docs/dev/tutorial.html
return 'Nothing here, sorry'
I have no success!
from bottle import route, response, error
I'm expecting that function is called when a unknown page is opened like
http://server:port/xx
192.168.178.26 - - [28/Feb/2017 20:42:20] "GET /xx HTTP/1.1" 404 729
But also syntax error resulting with html error 500 can't be catched.
What has to be checked / changed?
And is there a method to catch all python errors with one routine?
Can someone direct me to right tutorial or so ...
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Juerg Haefliger
2017-03-24 08:05:45 UTC
Permalink
What you can try is to use a wrapper to catch all exceptions and then
process them as you like. Have a look
at https://github.com/juergh/dwarf/blob/master/dwarf/exception.py#L27.
And it's used - for example -
here: https://github.com/juergh/dwarf/blob/master/dwarf/compute/api.py

Not sure if that's the right way but it was the best I could come up with
at the time :-)

...Juerg
Post by 'gNeandr' via bottlepy
Ok, one point was wrong with my code.
Because Bottle was called with
app = Bottle()
app.run(..)
@app.error(500)
@app.error(404)
But it doesn't give a general method to catch all html error codes with
one general and customized method/function.
There is a page on stackoverflow with an example contributed by Michael
<http://stackoverflow.com/questions/30854686/how-to-return-error-messages-in-json-with-bottle-httperror/42566998#42566998>,
but there is a point which let me struggle with it, just getting the normal
bottle html error page ... would like to pass/get more python and/or html
error details.
Any help?
With a good working bottle project I try to add an error handler, at best
it should catch all errors and direct to a special page with details what
fails in the module in question.
But also with the very simple example found on
https://bottlepy.org/docs/dev/tutorial.html
return 'Nothing here, sorry'
I have no success!
from bottle import route, response, error
I'm expecting that function is called when a unknown page is opened like
http://server:port/xx
192.168.178.26 - - [28/Feb/2017 20:42:20] "GET /xx HTTP/1.1" 404 729
But also syntax error resulting with html error 500 can't be catched.
What has to be checked / changed?
And is there a method to catch all python errors with one routine?
Can someone direct me to right tutorial or so ...
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...