class MyCustomErrorWithNoData extends TaggedApplicationError("custom-error-with-no-data") {}
class MyCustomErrorWithSomeData extends TaggedApplicationError("custom-error-with-some-data")<{
test: string
more: number
}> {
static code: string = "THIS TOO CAN BE OVERRIDE"
static message: string = "message can be override by extended class"
}
const errorWithNoData = new MyCustomErrorWithNoData("this is the api i am trying to achieve", { code: "RANDOM_LESS_THAN_0.5" })
// errorWithNoData.getData() <- undefined
const errorWithSomeData = new MyCustomErrorWithSomeData({
more: 1234,
test: "this is the random number in more"
})
// errorWithSomeData.more <- 1234
// errorWithSomeData.test <- 'this is the random number in more'
// errorWithSomeData.getData() <- this should give object of the data { more: 1234, test: 'this is the random number in more' }
class MyCustomErrorWithNoData extends TaggedApplicationError("custom-error-with-no-data") {}
class MyCustomErrorWithSomeData extends TaggedApplicationError("custom-error-with-some-data")<{
test: string
more: number
}> {
static code: string = "THIS TOO CAN BE OVERRIDE"
static message: string = "message can be override by extended class"
}
const errorWithNoData = new MyCustomErrorWithNoData("this is the api i am trying to achieve", { code: "RANDOM_LESS_THAN_0.5" })
// errorWithNoData.getData() <- undefined
const errorWithSomeData = new MyCustomErrorWithSomeData({
more: 1234,
test: "this is the random number in more"
})
// errorWithSomeData.more <- 1234
// errorWithSomeData.test <- 'this is the random number in more'
// errorWithSomeData.getData() <- this should give object of the data { more: 1234, test: 'this is the random number in more' }