หน้าเว็บ

วันจันทร์ที่ 24 ธันวาคม พ.ศ. 2555

custom exception type java

package com.blogspot.na5cent.librarys.exceptions;

/**
 *
 * @author Redcrow
 */
public class RequestClientsException extends Exception {

    public RequestClientsException() {
        super();
    }

    public RequestClientsException(String message) {
        super(message);
    }

    public RequestClientsException(String message, Throwable cause) {
        super(message, cause);
    }

    public RequestClientsException(Throwable cause) {
        super(cause);
    }
}

/**
* example
* public class RequestClients {
*
*    public static Integer requestInteger(String id) throws RequestClientsException  {
*         id = FacesContext.getCurrentInstance()
*                          .getExternalContext()
*                          .getRequestParameterMap()
*                          .get(id);
*         if (id == null) {
*             String message = "can't get parameter map of user, result map is null";
*             throw new RequestClientsException(message);
*         }
*         return Integer.valueOf(id);
*     }
* }
*
* public void onSelectUser() {
*     try {
*         userId = RequestClients.requestInteger("userId");
*     } catch (RequestClientsException ex) {
*         userId = -1;
*         LOG.warn("{}", ex.getMessage());
*     }
* }
*/

ไม่มีความคิดเห็น:

แสดงความคิดเห็น