sssom-js
Version:
Simple Standard for Sharing Ontology Mappings (SSOM) JavaScript library
29 lines (26 loc) • 645 B
JavaScript
import { positionString } from "./locators.js"
export class DetailledError extends Error {
constructor(msg, { position, value, cause } ) {
if (msg instanceof DetailledError) {
position ??= msg.position
value ??= msg.value
}
if (msg instanceof Error) {
msg = msg.message
}
super(msg, { cause })
this.position = position
this.value = value
}
toString() {
let msg = this.message || "Error"
let pos = positionString(this.position)
if (pos !== undefined) {
msg += ` at ${pos}`
}
if (this.value !== undefined) {
msg += `: ${this.value}`
}
return msg
}
}