KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > rmi > exception > NamingExceptionHelper


1 /**
2  * Copyright (C) 2005 - Bull S.A.
3  *
4  * CAROL: Common Architecture for RMI ObjectWeb Layer
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: NamingExceptionHelper.java,v 1.2 2005/04/07 15:07:08 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.carol.rmi.exception;
26
27 import javax.naming.NamingException JavaDoc;
28
29 /**
30  * This class throw NamingException by using provided exception, and set the
31  * initCause of the newly created exception. This avoid to forget initial
32  * exception
33  * @author Florent Benoit
34  */

35 public class NamingExceptionHelper {
36
37     /**
38      * Utility class, no constructor
39      */

40     private NamingExceptionHelper() {
41     }
42
43     /**
44      * Build a new exception with the given exception by wrapping it in a NamingException
45      * @return built exception
46      * @param message text error for the exception
47      * @param originalException original exception
48      */

49     public static NamingException JavaDoc create(String JavaDoc message, Exception JavaDoc originalException) {
50         NamingException JavaDoc ne = new NamingException JavaDoc(message);
51         ne.initCause(originalException);
52         return ne;
53     }
54
55     /**
56      * Build a new exception with the given error by wrapping it in a NamingException
57      * @return built exception
58      * @param message text error for the exception
59      * @param t original error
60      */

61     public static NamingException JavaDoc create(String JavaDoc message, Throwable JavaDoc t) {
62         NamingException JavaDoc ne = new NamingException JavaDoc(message);
63         ne.initCause(t);
64         return ne;
65     }
66
67 }
68
Popular Tags