package com.sandbox.runtime.models;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Used as a standard way to represent an error payload.
 * 
 * @author jayden
 * 
 */
@JsonInclude(Include.NON_NULL)
public class Error {
    private String displayMessage;
    private String detailedMessage;
    private String field;

    public Error() {
    }

    //display message is the few words error message shown to users
    //detailed message an optional amount of extra detail about the error, not generally shown to a UI user. Example is a JS validation error that is the failed code snippet
    //optional field if its a DTO validation error it would have an offending field name.
    public Error(String displayMessage) {
        this.displayMessage = displayMessage;
    }

    public Error(String displayMessage, String detailedMessage) {
        this.displayMessage = displayMessage;
        this.detailedMessage = detailedMessage;
    }

    public Error(String displayMessage, String detailedMessage, String field) {
        this.displayMessage = displayMessage;
        this.detailedMessage = detailedMessage;
        this.field = field;
    }

    @JsonProperty("detailed_message")
    public String getDetailedMessage() {
        return detailedMessage;
    }

    @JsonProperty("detailed_message")
    public void setDetailedMessage(String detailedMessage) {
        this.detailedMessage = detailedMessage;
    }

    @JsonProperty("message")
    public String getDisplayMessage() {
        return displayMessage;
    }

    @JsonProperty("message")
    public void setDisplayMessage(String displayMessage) {
        this.displayMessage = displayMessage;
    }

    public String getField() {
        return field;
    }
    
    public void setField(String field) {
        this.field = field;
    }

}

@@ -352,24 +352,50 @@
 ss Error %7B%0D%0A
+    private String code;%0D%0A
     private 
@@ -410,32 +410,32 @@
 isplayMessage;%0D%0A
-
     private Stri
@@ -850,16 +850,147 @@
  name.%0D%0A
+    //code is an optional error identifier, can be used by the consumer to drive any logic, such as UI elements for compensation.%0D%0A
     publ
@@ -1459,32 +1459,287 @@
 ield;%0D%0A    %7D%0D%0A%0D%0A
+    public Error(String displayMessage, String detailedMessage, String field, String code) %7B%0D%0A        this.displayMessage = displayMessage;%0D%0A        this.detailedMessage = detailedMessage;%0D%0A        this.field = field;%0D%0A        this.code = code;%0D%0A    %7D%0D%0A%0D%0A
     @JsonPropert
@@ -2410,11 +2410,147 @@
    %7D%0D%0A%0D%0A
+    public String getCode() %7B%0D%0A        return code;%0D%0A    %7D%0D%0A%0D%0A    public void setCode(String code) %7B%0D%0A        this.code = code;%0D%0A    %7D%0D%0A
 %7D%0D%0A

Add error code