001 /**
002 * <copyright>
003 *
004 * Copyright (c) 2005-2006 IBM Corporation and others.
005 * All rights reserved. This program and the accompanying materials
006 * are made available under the terms of the Eclipse Public License v1.0
007 * which accompanies this distribution, and is available at
008 * http://www.eclipse.org/legal/epl-v10.html
009 *
010 * Contributors:
011 * IBM - Initial API and implementation
012 *
013 * </copyright>
014 *
015 * $Id: DiagnosticException.java,v 1.3 2006/12/05 20:19:56 emerks Exp $
016 */
017 package org.eclipse.emf.common.util;
018
019 import org.eclipse.core.runtime.CoreException;
020
021 /**
022 * A checked exception representing a diagnosed failure.
023 * <p>
024 * Diagnostic exceptions contain a diagnostic describing the cause of the exception.
025 * </p>
026 * @see Diagnostic
027 */
028 public class DiagnosticException extends Exception
029 {
030 private static final long serialVersionUID = 1L;
031
032 private Diagnostic diagnostic;
033
034 public DiagnosticException(Diagnostic diagnostic)
035 {
036 super(diagnostic.getMessage(), diagnostic.getException());
037 this.diagnostic = diagnostic;
038 }
039
040 public final Diagnostic getDiagnostic()
041 {
042 return diagnostic;
043 }
044
045 public static CoreException toCoreException(DiagnosticException exception)
046 {
047 return new CoreException(BasicDiagnostic.toIStatus(exception));
048 }
049 }