Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. The Developer Center continues to support Commerce 6.13.0 through 7.4.1.Visit new site

DWR Exception Handling

DWR Exception Handling

Exception Handling

  • DWR can marshall exceptions, and they will become errors in Javascript (they can't be thrown since this will probably be happening asynchronously). The first parameter of the error handler contains the "message" of the caught exception i.e. the result of calling getMessage() on the exception. To have access to more information about the exception, we can "allow" DWR conversion of the exception object by adding:
    <convert converter="bean" match="com.elasticpath.service.EpServiceException">
      <param name="include" value="name, message, localizedMessage"/>
    </convert>
    
    to dwr.xml. The converted exception object will be the second parameter to the error handler.
  • In addition, to make it easy to identify the caught exception, we have added a "getName" method to EpServiceException. It will return the full classname of the caught exception, i.e. com.elasticpath.service.EmailExistException. Using this information, the specified field on the user input form can be highlighted.