add factory method with lineNumber

This commit is contained in:
Volker Berlin 2017-03-21 17:35:06 +01:00
parent 9baf237b4b
commit 82f41cbcd5

View File

@ -23,7 +23,7 @@ package de.inetsoftware.jwebassembly;
*/
public class WasmException extends Exception {
private final int lineNumber;
private int lineNumber;
/**
* Create a new instance.
@ -44,11 +44,28 @@ public class WasmException extends Exception {
* @param cause
* the cause
*/
WasmException( Throwable cause ) {
private WasmException( Throwable cause ) {
super( cause );
lineNumber = -1;
}
/**
* Create a wrapped exception needed.
*
* @param cause
* the wrapped cause
* @param lineNumber
* the line number in Java Code
* @return a new instance
*/
public static WasmException create( Throwable cause, int lineNumber ) {
WasmException wasmEx = create( cause );
if( wasmEx.lineNumber < 0 ) {
wasmEx.lineNumber = lineNumber;
}
return wasmEx;
}
/**
* Create a wrapped exception needed.
*