chore(event-bus): event bus error handling (#10085)

This commit is contained in:
Carlos R. L. Rodrigues
2024-11-13 18:03:29 -03:00
committed by GitHub
parent 98bf8c9006
commit 3e265229f2
9 changed files with 78 additions and 56 deletions
@@ -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,