I am looking to customize the error message in my RunTimeError class by overriding the asString function, as I need it to be different from the one in my generic Error class
class Error {
errorName: string;
details: string;
posStart: Position;
posEnd: Position;
constructor({errorName, details, posStart, posEnd}: ErrorTypes) {
this.errorName = errorName
this.details = details
this.posStart = posStart
this.posEnd = posEnd
}
asString() {
let result: string = `${this.errorName} on line ${this.posStart.ln+1}: ${this.details}`
return result
}
}
class RunTimeError extends Error {
context: any
constructor({details, posStart, posEnd, context}: SubErrorTypes) {
super({errorName:"Runtime Error", details:details, posStart:posStart, posEnd:posEnd})
this.context = context
}
//change contents of asString
}