Sunday, January 23, 2011

OAF Best Practices (Error / Exception Handling)

A. Catching Exceptions

Catch exceptions within the controllers. When exceptions occur inside the application module, throw it back using

which means you also need to register your Exception messages in Oracle Apps


something like this @w@;; but I think you could do away with the catch block, unless you wanted to do something before the OAException object is finally thrown back to the controller.

B. Logging the Errors

syntax: pageContext.writeDiagnostics(String module, String messageText, int logLevel)

where the parameter module could be getClass.getName() + ".processFormRequest" (or ".processRequest"), so it will dynamically print out the class name regardless where you call it.

message could be any String  I guess @w@ use it with discretion. (limited to 4000 characters according to the documentation)

logLevel value could be referenced from OAFwkConstants (just noticed Fwk = framework @w@). So in cases you want to log Excpetion details, use OAFwkConstants.EXCEPTION which is numerically equivalent to 4.



in the example syntax, I used an instance of OAPageContext which is available for controllers. If in case you want to log things inside the application module you need to use an instance of OADBTransaction which has the same method.

sources:
The Digital Space

No comments:

Post a Comment