What could go wrong with Visualforce Code ?
When the visualforce page renders in UI, it goes through different layers of processing,- Controller/Extension Object Creation for page
- Invoke Action method for Page
- Controller Creation for Component
- Initialization of Components
- Rendering each binding variables
What are the places to take more care ?
One need to take more care in following cases,Handling null values - To avoid, initialize all variables in Constructor or at declaration.
Handling mathematical exceptions - To avoid, careful about divide by zero cases
Handling Network exception - To avoid, always try-catch CalloutException
Handling DML exceptions - To avoid, always try-catch DMLException
Handling NoDataFound exception - To avoid, always try catch Soql query section
There are many other possible cases, but i have highlighted common cases above.
What are the ways to report error ?
Between controller & visualforce page, there's one way of error communication which is through ApexPages.MessageHow to handle them gracefully ?
Ideally, there should be no unhandled exception. In that case, salesforce will throw the raw error to User without proceeding after the error.Where can the error be reported in UI ?
It can be reported in following places in UI,- Top section in the page
- Above any group of components
- Exactly below the component
No comments:
Post a Comment
Thanks for reading my blog !