chore(event-bus): event bus error handling (#10085)
This commit is contained in:
@@ -58,30 +58,3 @@ export class TransactionTimeoutError extends Error {
|
||||
this.name = "TransactionTimeoutError"
|
||||
}
|
||||
}
|
||||
|
||||
export function serializeError(error) {
|
||||
const serialized = {
|
||||
message: error.message,
|
||||
name: error.name,
|
||||
stack: error.stack,
|
||||
}
|
||||
|
||||
Object.getOwnPropertyNames(error).forEach((key) => {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (!serialized.hasOwnProperty(key)) {
|
||||
serialized[key] = error[key]
|
||||
}
|
||||
})
|
||||
|
||||
return serialized
|
||||
}
|
||||
|
||||
export function isErrorLike(value) {
|
||||
return (
|
||||
!!value &&
|
||||
typeof value === "object" &&
|
||||
"name" in value &&
|
||||
"message" in value &&
|
||||
"stack" in value
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,12 +17,16 @@ import {
|
||||
TransactionStepStatus,
|
||||
} from "./types"
|
||||
|
||||
import { MedusaError, promiseAll, TransactionStepState } from "@medusajs/utils"
|
||||
import { EventEmitter } from "events"
|
||||
import {
|
||||
isErrorLike,
|
||||
PermanentStepFailureError,
|
||||
MedusaError,
|
||||
promiseAll,
|
||||
serializeError,
|
||||
TransactionStepState,
|
||||
} from "@medusajs/utils"
|
||||
import { EventEmitter } from "events"
|
||||
import {
|
||||
PermanentStepFailureError,
|
||||
SkipStepResponse,
|
||||
TransactionStepTimeoutError,
|
||||
TransactionTimeoutError,
|
||||
|
||||
Reference in New Issue
Block a user