@tamara-solution/checkout
Version:
Script will be embedded in merchant's site to checkout. The merchant's don't need to redirect to tamara's site.
52 lines (42 loc) • 1.25 kB
JavaScript
const ERROR_PREFIX = 'TAMARA-CHECKOUT >>> '
/**
* For fixing empty message and wrong stacktrace
* https://stackoverflow.com/questions/31089801/extending-error-in-javascript-with-es6-syntax-babel
*/
class ExtendableError extends Error {
constructor(message) {
super(message)
this.name = this.constructor.name
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor)
} else {
this.stack = new Error(message).stack
}
}
}
class ExtendableTypeError extends TypeError {
constructor(message) {
super(message)
this.name = this.constructor.name
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor)
} else {
this.stack = new Error(message).stack
}
}
}
class FrameError extends ExtendableError {
constructor(message, payload) {
const tamaraMessage = ERROR_PREFIX + message
super(tamaraMessage)
this.payload = payload
}
}
class TamaraTypeError extends ExtendableTypeError {
constructor(message, payload) {
const tamaraMessage = ERROR_PREFIX + message
super(tamaraMessage)
this.payload = payload
}
}
export { FrameError, ExtendableError, TamaraTypeError }