/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{clone as t}from"./lang.js";import e from"./Logger.js";import{substitute as s}from"./string.js";class r{constructor(t,e,r){this.type="error",this.name=t,this.message=e?s(e,r):"",this.details=r}toString(){const{name:t,message:e}=this;return`[${t}]: ${e}`}toJSON(){if(null!=this.details)try{return{name:this.name,message:this.message,details:JSON.parse(JSON.stringify(this.details,(e,s)=>{if(s&&"object"==typeof s&&"function"==typeof s.toJSON)return s;try{return t(s)}catch(r){return"[object]"}}))}}catch(s){throw e.getLogger("esri.core.Error").error(s),s}return{name:this.name,message:this.message,details:this.details}}static fromJSON(t){return new r(t.name,t.message,t.details)}}export{r as default};
