From 82f41cbcd5d56732a5ab0f4ef2828d9a9c888700 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Tue, 21 Mar 2017 17:35:06 +0100 Subject: [PATCH] add factory method with lineNumber --- .../jwebassembly/WasmException.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/WasmException.java b/src/de/inetsoftware/jwebassembly/WasmException.java index e9b9b33..b07aede 100644 --- a/src/de/inetsoftware/jwebassembly/WasmException.java +++ b/src/de/inetsoftware/jwebassembly/WasmException.java @@ -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. *