Move message formatting to StatementSourceException
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / meta / StatementSourceException.java
index 9f056480185d2a1f1aeffcf751f618217d3fabbf..324d16858ab0635b3c216a6aa0c43c4eeb1da121 100644 (file)
@@ -27,20 +27,23 @@ public class StatementSourceException extends RuntimeException {
     private final @NonNull StatementSourceReference sourceRef;
 
     public StatementSourceException(final StatementSourceReference sourceRef, final String message) {
-        super(message);
+        super(createMessage(sourceRef, message));
         this.sourceRef = requireNonNull(sourceRef);
     }
 
     public StatementSourceException(final StatementSourceReference sourceRef, final String message,
             final Throwable cause) {
-        super(message, cause);
+        super(createMessage(sourceRef, message), cause);
         this.sourceRef = requireNonNull(sourceRef);
     }
 
     public StatementSourceException(final StatementSourceReference sourceRef, final String format,
             final Object... args) {
-        super(format.formatted(args));
-        this.sourceRef = requireNonNull(sourceRef);
+        this(sourceRef, format.formatted(args));
+    }
+
+    private static String createMessage(final StatementSourceReference sourceRef, final String message) {
+        return requireNonNull(message) + " [at " + requireNonNull(sourceRef) + ']';
     }
 
     /**