KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > jet > JETException


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: JETException.java,v 1.3 2005/06/08 06:15:57 nickb Exp $
16  */

17 package org.eclipse.emf.codegen.jet;
18
19
20 import org.eclipse.core.runtime.CoreException;
21 import org.eclipse.core.runtime.IStatus;
22 import org.eclipse.core.runtime.Status;
23
24 import org.eclipse.emf.codegen.CodeGenPlugin;
25
26
27
28 /**
29  * Base class for all exceptions generated by the JET engine.
30  * Makes it convienient to catch just this at the top-level.
31  */

32 public class JETException extends CoreException
33 {
34   public JETException(String JavaDoc reason)
35   {
36     super(new Status(IStatus.ERROR, CodeGenPlugin.INSTANCE.getSymbolicName(), 0, reason, null));
37   }
38
39   /**
40    * Creates a JETException with the embedded exception and the reason for throwing a JETException.
41    */

42   public JETException (String JavaDoc reason, Throwable JavaDoc exception)
43   {
44     super(new Status(IStatus.ERROR, CodeGenPlugin.INSTANCE.getSymbolicName(), 0, reason, exception));
45   }
46
47   /**
48    * Creates a JETException with the embedded exception.
49    */

50   public JETException (Throwable JavaDoc exception)
51   {
52     super
53       (new Status
54         (IStatus.ERROR, CodeGenPlugin.INSTANCE.getSymbolicName(), 0, getMessage(exception), exception));
55   }
56
57   protected static String JavaDoc getMessage(Throwable JavaDoc exception)
58   {
59     String JavaDoc result = exception.getLocalizedMessage();
60     if (result == null)
61     {
62       result = "";
63     }
64
65     return result;
66   }
67 }
68
Popular Tags