chore(event-bus): event bus error handling (#10085)
This commit is contained in:
committed by
GitHub
parent
98bf8c9006
commit
3e265229f2
@@ -18,6 +18,7 @@ export * from "./dynamic-import"
|
||||
export * from "./env-editor"
|
||||
export * from "./errors"
|
||||
export * from "./file-system"
|
||||
export * from "./filter-operator-map"
|
||||
export * from "./generate-entity-id"
|
||||
export * from "./get-caller-file-path"
|
||||
export * from "./get-config-file"
|
||||
@@ -34,6 +35,7 @@ export * from "./is-boolean"
|
||||
export * from "./is-date"
|
||||
export * from "./is-defined"
|
||||
export * from "./is-email"
|
||||
export * from "./is-error-like"
|
||||
export * from "./is-object"
|
||||
export * from "./is-present"
|
||||
export * from "./is-string"
|
||||
@@ -62,6 +64,7 @@ export * from "./remove-undefined-properties"
|
||||
export * from "./resolve-exports"
|
||||
export * from "./rules"
|
||||
export * from "./selector-constraints-to-string"
|
||||
export * from "./serialize-error"
|
||||
export * from "./set-metadata"
|
||||
export * from "./simple-hash"
|
||||
export * from "./string-to-select-relation-object"
|
||||
@@ -74,4 +77,3 @@ export * from "./trim-zeros"
|
||||
export * from "./upper-case-first"
|
||||
export * from "./validate-handle"
|
||||
export * from "./wrap-handler"
|
||||
export * from "./filter-operator-map"
|
||||
|
||||
9
packages/core/utils/src/common/is-error-like.ts
Normal file
9
packages/core/utils/src/common/is-error-like.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export function isErrorLike(value) {
|
||||
return (
|
||||
!!value &&
|
||||
typeof value === "object" &&
|
||||
"name" in value &&
|
||||
"message" in value &&
|
||||
"stack" in value
|
||||
)
|
||||
}
|
||||
16
packages/core/utils/src/common/serialize-error.ts
Normal file
16
packages/core/utils/src/common/serialize-error.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user