From dc1128cb2e483126fa1a9ae0afef78cc370ca107 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sun, 19 Mar 2017 18:06:53 +0100 Subject: [PATCH] add factory method --- .../jwebassembly/CompileException.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/JWebAssembly/src/de/inetsoftware/jwebassembly/CompileException.java b/JWebAssembly/src/de/inetsoftware/jwebassembly/CompileException.java index 95f0977..497ae36 100644 --- a/JWebAssembly/src/de/inetsoftware/jwebassembly/CompileException.java +++ b/JWebAssembly/src/de/inetsoftware/jwebassembly/CompileException.java @@ -23,4 +23,27 @@ package de.inetsoftware.jwebassembly; */ public class CompileException extends Exception { + /** + * Create a new instance with a cause. + * + * @param cause + * the cause + */ + CompileException( Throwable cause ) { + super( cause ); + } + + /** + * Create a wrapped exception needed. + * + * @param cause + * the wrapped cause + * @return a new instance + */ + public static CompileException create( Throwable cause ) { + if( cause instanceof CompileException ) { + return (CompileException)cause; + } + return new CompileException( cause ); + } }