0

I know that global try catch for Python does exist, what about Java implementation ?

Thanks, Efi

Community
  • 1
  • 1
Efi MK
  • 1,022
  • 1
  • 11
  • 26
  • Can you please describe what does the global try-catch do in Python, or post a link to an article which describes it? That would help us who know Java but not Python, to give you an answer. – ignis Jun 07 '11 at 18:40
  • Click on the Python word. http://stackoverflow.com/questions/4296504/catch-all-global-exception-handler-in-app-engine-for-python – Efi MK Jun 07 '11 at 18:48
  • whopps :P Well, I think shuai is right, then – ignis Jun 07 '11 at 18:53

1 Answers1

1

Don't know about Python. But I think you can just add try-catch(Exception e) as the top-level in your post()/get() method. But please note unnecessary try-catch is a cost of performance and I don't think simply using catch(Exception e) is a good way of programming. You may suffer and spend more time to debug later.

shuaiyuancn
  • 2,744
  • 3
  • 24
  • 32
  • Agree, how would you recommend implementing writing logs on each exception. – Efi MK Jun 07 '11 at 18:50
  • See package java.util.logging http://download.oracle.com/javase/6/docs/api/java/util/logging/package-summary.html – ignis Jun 07 '11 at 18:55
  • I'm using this package, so the question is what is the best paradigm to use when logging. Should I do it on every try catch (can cause multiple logs with the same message) ? – Efi MK Jun 07 '11 at 19:01
  • @Efi I think you can log every detail you want but using proper granularity control like debug()/info()/severe(). I do logging all the time and log every crucial parameter during processing. You can easily switch to certain level of log output when switching to productivity deployment. You can try throwing all exceptions in inner logic but catch them in the out most logic, like in post()/get(), individually rather than a simple Exception to catch all. – shuaiyuancn Jun 08 '11 at 14:03