# COSMOS Developer's Guide

### Error Handling

The COMSOS UI defines a default error handler object that is defined as a Dojo object (for example,`org.eclipse.cosmos.provisional.dr.ps.components.utility.ErrorHandler`). This allows you to extend or replace the error handler by utilizing the Dojo programming model.

The error handler utilizes the dojotopic system. This system makes it easy for separate components to communicate without explicit knowledge of one another's internal implementations. The error handler object subscribes to the `org.eclipse.cosmos.provisional.dr.ps.components.utility.ErrorHandler` topic. Web components can publish their error message to this topic to log the error. The following sample shows how this is accomplished.

       dojo.publish("org.eclipse.cosmos.provisional.dr.ps.components.utility.ErrorHandler",
        [{message:{message:"My Message", detail:"Message details"}, prompt:true, severity:1}]);

The above line of code publishes a message object to the error handler topic. The message object has the following structure.

    {
       //message: Object
       //  object that contains the message information
       message:{
                  //message:String
                  //   text summary of the message
                  message:"",
                  //detail:String
                  //   text detail of the message
                  detail:""
               },
       //prompt:Boolean
       //  set to true if the message should prompt the user with the message, false otherwise.
       prompt:true,
       //severity: Integer
       //  indicates the severity of the message.  The following are values for severity:
       //     1 - ERROR
       //     2 - INFO
       //     4 - WARNING
       //     0 - NONE
       severity:1
    }

Server Side Logging

The default error handler object provides a means for a server side component to receive error messages from the client. The client uses the post method to send logged messages from the client to the server side error component. The following define the POST arguments sent in the request to the server component

message
  a string representation of the message
severity
  this is a numeric value 1, 2, or 4 representing an error, informational or warning message, respectively.

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]