/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2002-2011 Ausenco Engineering Canada Inc.
 *
 * 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.jaamsim.basicsim;

/**
 * Custom exception thrown when a program error is encountered.
 */
public class ErrorException extends RuntimeException {
	public ErrorException(String format, Object... args) {
		super(String.format(format, args));
	}

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

@@ -92,16 +92,60 @@
 da Inc.%0A
+ * Copyright (C) 2016 JaamSim Software Inc.%0A
  *%0A * Li
@@ -729,16 +729,52 @@
 icsim;%0A%0A
+import com.jaamsim.input.ExpError;%0A%0A
 /**%0A * C
@@ -892,16 +892,228 @@
 ption %7B%0A
+%0A%09public String entName;%0A%09public String source;%0A%09public int position;%0A%0A%09public ErrorException(int pos, String src, String name, String msg) %7B%0A%09%09super(msg);%0A%09%09entName = name;%0A%09%09source = src;%0A%09%09position = pos;%0A%09%7D%0A%0A
 %09public 
@@ -1162,22 +1162,33 @@
 gs) %7B%0A%09%09
-super(
+this(-1, %22%22, %22%22, 
 String.f
@@ -1240,48 +1240,535 @@
 ion(
- Throwable cause ) %7B%0A%09%09super( cause );%0A%09%7D
+Entity ent, String msg) %7B%0A%09%09this(-1, %22%22, ent.getName(), msg);%0A%09%7D%0A%0A%09public ErrorException(Entity ent, ExpError e) %7B%0A%09%09this(e.pos, e.source, ent.getName(), e.getMessage());%0A%09%7D%0A%0A%09public ErrorException( Throwable cause ) %7B%0A%09%09super( cause );%0A%09%09entName = %22%22;%0A%09%09source = %22%22;%0A%09%09position = -1;%0A%09%7D%0A%0A%09@Override%0A%09public String getMessage() %7B%0A%09%09if (entName.isEmpty()) %7B%0A%09%09%09return super.getMessage();%0A%09%09%7D%0A%09%09StringBuilder sb = new StringBuilder();%0A%09%09sb.append(entName).append(%22: %22);%0A%09%09sb.append(super.getMessage());%0A%09%09return sb.toString();%0A%09%7D%0A
 %0A%7D%0A

store expression error data in ErrorException