UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 771 B
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ 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};