package org.radarcns.management.web.rest.errors;

import java.util.HashMap;
import java.util.Map;

/**
 * Custom, parameterized exception, which can be translated on the client side.
 * For example:
 *
 * <pre>
 * throw new CustomParameterizedException(&quot;myCustomError&quot;, &quot;hello&quot;, &quot;world&quot;);
 * </pre>
 *
 * Can be translated with:
 *
 * <pre>
 * "error.myCustomError" :  "The server says {{param0}} to {{param1}}"
 * </pre>
 */
public class CustomParameterizedException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private static final String PARAM = "param";

    private final String message;

    private final Map<String, String> paramMap = new HashMap<>();

    public CustomParameterizedException(String message, String... params) {
        super(message);
        this.message = message;
        if (params != null && params.length > 0) {
            for (int i = 0; i < params.length; i++) {
                paramMap.put(PARAM + i, params[i]);
            }
        }
    }

    public CustomParameterizedException(String message, Map<String, String> paramMap) {
        super(message);
        this.message = message;
        this.paramMap.putAll(paramMap);
    }

    public ParameterizedErrorVM getErrorVM() {
        return new ParameterizedErrorVM(message, paramMap);
    }
}

@@ -43,16 +43,74 @@
 rrors;%0A%0A
+import java.text.SimpleDateFormat;%0Aimport java.util.Date;%0A
 import j
@@ -907,32 +907,229 @@
 sage = message;%0A
+        // add default timestamp first, so a timestamp key in the paramMap will overwrite it%0A        this.paramMap.put(%22timestamp%22, new SimpleDateFormat(%22yyyy-MM-dd HH:mm:ss%22).format(new Date()));%0A
         if (para
@@ -1436,32 +1436,229 @@
 sage = message;%0A
+        // add default timestamp first, so a timestamp key in the paramMap will overwrite it%0A        this.paramMap.put(%22timestamp%22, new SimpleDateFormat(%22yyyy-MM-dd HH:mm:ss%22).format(new Date()));%0A
         this.par

Make CustomParameterizedException add a timestamp by default