/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.debugger.engine.evaluation;

import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.InvocationException;
import com.sun.jdi.ObjectReference;
import org.jetbrains.annotations.Nullable;

public class EvaluateException extends Exception {
  private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.evaluation.EvaluateException");
  private ObjectReference myTargetException;

  public EvaluateException(final String message) {
    super(message);
    if (LOG.isDebugEnabled()) {
      LOG.debug(message);
    }
  }

  public EvaluateException(String msg, Throwable th) {
    super(msg, th);
    if (th instanceof EvaluateException) {
      myTargetException = ((EvaluateException)th).getExceptionFromTargetVM();
    }
    else if(th instanceof InvocationException){
      InvocationException invocationException = (InvocationException) th;
      myTargetException = invocationException.exception();
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug(msg);
    }
  }
  
  @Nullable
  public ObjectReference getExceptionFromTargetVM() {
    return myTargetException;
  }

  public void setTargetException(final ObjectReference targetException) {
    myTargetException = targetException;
  }
}
@@ -1841,10 +1841,370 @@
 ion;%0A  %7D
+%0A%0A  public String getMessage() %7B%0A    final String errorMessage = super.getMessage();%0A    if (errorMessage != null) %7B%0A      return errorMessage;%0A    %7D%0A    final Throwable cause = getCause();%0A    final String causeMessage = cause != null? cause.getMessage() : null;%0A    if (causeMessage != null) %7B%0A      return causeMessage;%0A    %7D%0A    return %22unknown error%22;%0A  %7D
 %0A%7D

fix NPE