jczic / MicroWebSrv

A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
https://github.com/jczic/MicroWebSrv
MIT License
645 stars 116 forks source link

Print the traceback when route handler raises an Exception #67

Closed omarbenhamid closed 5 years ago

omarbenhamid commented 5 years ago

Current Behaviour : When handler raises an exception we have an HTTP 500 internal error but no clue of the reason.

New Behaviour: Print the Exception Traceback on the serial console allowing easier debug the handler code.

jczic commented 5 years ago

Hi, it's a good idea but "sys.print_exception" is dedicated to micropython and just prints exception value. https://docs.micropython.org/en/latest/library/sys.html

It's more simple to catch like that :

try
    ....
except Exception as ex :
    print('Route %s code exception : %s' % (routeinfo..., ex))

no?

jczic commented 5 years ago

Can you check : https://github.com/jczic/MicroWebSrv/commit/dd660d994a859de065147b4ccdaeea935b5465d3

omarbenhamid commented 5 years ago

sys.print_exception shows the full Traceback wheras print only shows the exception message which is often not enough for a developer to know where the error comes from. Yes it is specific to micropython, CPython has traceback module which does this. Télécharger Outlook pour Android

On Tue, Sep 24, 2019 at 8:11 AM +0200, "J-Christophe Bos" notifications@github.com wrote:

Closed #67.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jczic commented 4 years ago

Hello,

I released a fully new version (v2.0) of my web server here : github.com/jczic/MicroWebSrv2. Open source MIT, fully asynchronous, more robust, more fast and more efficient! It is delivered with a good documentation.

Thank you for your support and feedback. ☺️

Jean-Christophe Bos

Le mar. 24 sept. 2019 à 10:18, Omar BENHAMID notifications@github.com a écrit :

sys.print_exception shows the full Traceback wheras print only shows the exception message which is often not enough for a developer to know where the error comes from. Yes it is specific to micropython, CPython has traceback module which does this. Télécharger Outlook pour Android

On Tue, Sep 24, 2019 at 8:11 AM +0200, "J-Christophe Bos" < notifications@github.com> wrote:

Closed #67.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/jczic/MicroWebSrv/pull/67?email_source=notifications&email_token=AAD2ALGHJXF6AF4TJ4Q5OHLQLHEMHA5CNFSM4IZP7T4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7NQN3Y#issuecomment-534447855, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD2ALH3CMGTWQWATGM463LQLHEMHANCNFSM4IZP7T4A .

--

Sincèrement,