Skip to content

Instantly share code, notes, and snippets.

@bundle-js
Created October 31, 2023 18:52
Show Gist options
  • Save bundle-js/ea58ded764f2503ffe4cda41f7e980e2 to your computer and use it in GitHub Desktop.
Save bundle-js/ea58ded764f2503ffe4cda41f7e980e2 to your computer and use it in GitHub Desktop.
function c(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?l(t.position):"start"in t||"end"in t?l(t):"line"in t||"column"in t?p(t):""}function p(t){return y(t&&t.line)+":"+y(t&&t.column)}function l(t){return p(t&&t.start)+"-"+p(t&&t.end)}function y(t){return t&&typeof t=="number"?t:1}var i=class extends Error{constructor(o,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let u="",e={},r=!1;if(n&&("line"in n&&"column"in n?e={place:n}:"start"in n&&"end"in n?e={place:n}:"type"in n?e={ancestors:[n],place:n.position}:e={...n}),typeof o=="string"?u=o:!e.cause&&o&&(r=!0,u=o.message,e.cause=o),!e.ruleId&&!e.source&&typeof s=="string"){let f=s.indexOf(":");f===-1?e.ruleId=s:(e.source=s.slice(0,f),e.ruleId=s.slice(f+1))}if(!e.place&&e.ancestors&&e.ancestors){let f=e.ancestors[e.ancestors.length-1];f&&(e.place=f.position)}let d=e.place&&"start"in e.place?e.place.start:e.place;this.ancestors=e.ancestors||void 0,this.cause=e.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file,this.message=u,this.line=d?d.line:void 0,this.name=c(e.place)||"1:1",this.place=e.place||void 0,this.reason=this.message,this.ruleId=e.ruleId||void 0,this.source=e.source||void 0,this.stack=r&&e.cause&&typeof e.cause.stack=="string"?e.cause.stack:"",this.actual,this.expected,this.note,this.url}};i.prototype.file="";i.prototype.name="";i.prototype.reason="";i.prototype.message="";i.prototype.stack="";i.prototype.column=void 0;i.prototype.line=void 0;i.prototype.ancestors=void 0;i.prototype.cause=void 0;i.prototype.fatal=void 0;i.prototype.place=void 0;i.prototype.ruleId=void 0;i.prototype.source=void 0;export{i as VFileMessage};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment