@zudojs/errors 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +29 -8
- package/dist/base/core/baseError.core.d.ts +25 -2
- package/dist/base/core/baseError.core.js +95 -23
- package/dist/base/core/errorMetadata.core.d.ts +62 -5
- package/dist/base/core/errorMetadata.core.js +280 -23
- package/dist/base/types/errorCategory.helpers.js +3 -2
- package/dist/base/types/errorCode.type.d.ts +70 -1
- package/dist/base/types/errorCode.type.js +78 -2
- package/dist/base/types/errorSeverity.type.js +3 -2
- package/dist/base/utils/baseError.utils.d.ts +18 -2
- package/dist/base/utils/baseError.utils.js +68 -17
- package/dist/domain/access/rateLimit.error.d.ts +6 -1
- package/dist/domain/access/rateLimit.error.js +7 -9
- package/dist/domain/api/apiError.base.js +2 -2
- package/dist/domain/api/apiError.lifecycle.d.ts +10 -1
- package/dist/domain/api/apiError.lifecycle.js +22 -7
- package/dist/domain/api/apiError.routing.js +4 -4
- package/dist/domain/app/domain.error.d.ts +2 -0
- package/dist/domain/app/domain.error.js +3 -1
- package/dist/domain/app/lifecycleError.types.js +2 -8
- package/dist/domain/app/moduleError.types.d.ts +3 -0
- package/dist/domain/app/moduleError.types.js +6 -2
- package/dist/domain/body/bodyParser.error.d.ts +9 -2
- package/dist/domain/body/bodyParser.error.js +20 -12
- package/dist/domain/body/httpBodyError.base.js +1 -2
- package/dist/domain/body/httpBodyError.types.js +1 -3
- package/dist/domain/body/httpFormData.error.js +2 -4
- package/dist/domain/body/multipart.error.js +2 -4
- package/dist/domain/documentation/documentationError.base.js +4 -2
- package/dist/domain/documentation/documentationError.types.js +1 -11
- package/dist/domain/documentation/index.d.ts +1 -1
- package/dist/domain/documentation/index.js +1 -1
- package/dist/domain/event/event.error.d.ts +1 -1
- package/dist/domain/event/event.error.js +1 -1
- package/dist/domain/event/eventError.base.d.ts +4 -1
- package/dist/domain/event/eventError.base.js +7 -9
- package/dist/domain/event/eventError.handler.d.ts +12 -3
- package/dist/domain/event/eventError.handler.js +21 -11
- package/dist/domain/event/eventError.lifecycle.d.ts +20 -3
- package/dist/domain/event/eventError.lifecycle.js +48 -18
- package/dist/domain/event/eventError.serialization.d.ts +10 -2
- package/dist/domain/event/eventError.serialization.js +16 -4
- package/dist/domain/message/message.error.d.ts +1 -0
- package/dist/domain/message/message.error.js +1 -0
- package/dist/domain/message/messageError.base.d.ts +4 -1
- package/dist/domain/message/messageError.base.js +7 -9
- package/dist/domain/message/messageError.handler.d.ts +12 -3
- package/dist/domain/message/messageError.handler.js +22 -12
- package/dist/domain/message/messageError.lifecycle.d.ts +5 -1
- package/dist/domain/message/messageError.lifecycle.js +15 -8
- package/dist/domain/message/messageError.serialization.d.ts +26 -0
- package/dist/domain/message/messageError.serialization.js +35 -0
- package/dist/domain/plugin/pluginError.lifecycle.js +23 -21
- package/dist/domain/plugin/pluginError.runtime.d.ts +5 -1
- package/dist/domain/plugin/pluginError.runtime.js +12 -7
- package/dist/domain/queue/queueError.base.d.ts +19 -0
- package/dist/domain/queue/queueError.base.js +24 -4
- package/dist/domain/queue/queueError.job.js +2 -0
- package/dist/domain/queue/queueError.worker.d.ts +9 -3
- package/dist/domain/queue/queueError.worker.js +14 -6
- package/dist/domain/rpc/rpcError.base.js +0 -2
- package/dist/domain/rpc/rpcError.protocol.js +0 -7
- package/dist/domain/rpc/rpcError.transport.d.ts +10 -1
- package/dist/domain/rpc/rpcError.transport.js +19 -9
- package/dist/domain/scheduler/schedulerError.base.d.ts +17 -3
- package/dist/domain/scheduler/schedulerError.base.js +26 -15
- package/dist/domain/scheduler/schedulerError.execution.d.ts +7 -6
- package/dist/domain/scheduler/schedulerError.execution.js +22 -18
- package/dist/domain/scheduler/schedulerError.schedule.d.ts +15 -5
- package/dist/domain/scheduler/schedulerError.schedule.js +32 -14
- package/dist/domain/schema/index.d.ts +2 -1
- package/dist/domain/schema/index.js +1 -1
- package/dist/domain/schema/schemaError.base.d.ts +31 -5
- package/dist/domain/schema/schemaError.base.js +34 -6
- package/dist/domain/schema/schemaError.types.js +12 -5
- package/dist/domain/serialization/serializationError.base.d.ts +8 -2
- package/dist/domain/serialization/serializationError.base.js +38 -8
- package/dist/domain/serialization/serializationError.types.d.ts +22 -3
- package/dist/domain/serialization/serializationError.types.js +30 -5
- package/dist/domain/shared/domainError.helpers.d.ts +60 -0
- package/dist/domain/shared/domainError.helpers.js +191 -0
- package/dist/domain/state/conflict.error.d.ts +1 -1
- package/dist/domain/state/conflict.error.js +2 -2
- package/dist/domain/state/validationError.base.d.ts +8 -1
- package/dist/domain/state/validationError.base.js +11 -2
- package/dist/infrastructure/adapter/adapterError.base.js +6 -6
- package/dist/infrastructure/adapter/adapterError.lifecycle.js +0 -3
- package/dist/infrastructure/adapter/adapterError.operation.js +0 -5
- package/dist/infrastructure/cache/cacheError.base.js +1 -1
- package/dist/infrastructure/container/containerError.registration.js +6 -4
- package/dist/infrastructure/network/httpAdapter.error.js +4 -2
- package/dist/infrastructure/network/httpClientError.advanced.js +10 -18
- package/dist/infrastructure/network/httpClientError.base.d.ts +11 -0
- package/dist/infrastructure/network/httpClientError.base.js +47 -7
- package/dist/infrastructure/network/httpClientError.common.d.ts +14 -0
- package/dist/infrastructure/network/httpClientError.common.js +21 -31
- package/dist/infrastructure/network/httpClientError.specialized.js +5 -8
- package/dist/infrastructure/network/httpClientError.types.d.ts +23 -2
- package/dist/infrastructure/network/httpClientError.types.js +55 -42
- package/dist/infrastructure/network/httpResponse.error.js +0 -3
- package/dist/infrastructure/network/httpRouterError.base.js +0 -1
- package/dist/infrastructure/network/httpRouterError.types.d.ts +5 -3
- package/dist/infrastructure/network/httpRouterError.types.js +6 -7
- package/dist/infrastructure/network/httpServerError.error.js +6 -10
- package/dist/infrastructure/network/httpServerLifecycleError.base.js +0 -1
- package/dist/infrastructure/network/httpServerLifecycleError.types.js +0 -3
- package/dist/infrastructure/network/httpStream.error.js +0 -1
- package/dist/infrastructure/network/network.error.d.ts +1 -1
- package/dist/infrastructure/network/network.error.js +1 -1
- package/dist/infrastructure/network/networkError.factory.d.ts +9 -2
- package/dist/infrastructure/network/networkError.factory.js +9 -2
- package/dist/infrastructure/network/routePattern.error.d.ts +7 -6
- package/dist/infrastructure/network/routePattern.error.js +16 -8
- package/dist/infrastructure/network/timeoutError.base.d.ts +7 -0
- package/dist/infrastructure/network/timeoutError.base.js +12 -1
- package/dist/infrastructure/network/timeoutError.factory.d.ts +14 -0
- package/dist/infrastructure/network/timeoutError.factory.js +25 -17
- package/dist/infrastructure/service/externalService.error.d.ts +1 -1
- package/dist/infrastructure/service/externalService.error.js +1 -1
- package/dist/infrastructure/service/externalServiceError.base.d.ts +8 -0
- package/dist/infrastructure/service/externalServiceError.base.js +8 -11
- package/dist/infrastructure/service/externalServiceError.factory.d.ts +3 -1
- package/dist/infrastructure/service/externalServiceError.factory.js +3 -1
- package/dist/infrastructure/storage/databaseError.factory.js +1 -1
- package/dist/infrastructure/storage/storageError.factory.js +2 -2
- package/dist/system/cryptoError.factory.js +5 -2
- package/dist/system/runtimeError.base.js +1 -1
- package/dist/utils/errorHandler.core.d.ts +42 -8
- package/dist/utils/errorHandler.core.js +116 -63
- package/dist/utils/errorHandler.factory.d.ts +1 -1
- package/dist/utils/errorHandler.factory.js +2 -2
- package/dist/utils/errorHandler.types.d.ts +37 -1
- package/dist/utils/errorMapper.core.d.ts +1 -1
- package/dist/utils/errorMapper.core.js +1 -1
- package/dist/utils/errorMapper.mappers.d.ts +27 -6
- package/dist/utils/errorMapper.mappers.js +57 -49
- package/dist/utils/errorSerializer.core.d.ts +22 -3
- package/dist/utils/errorSerializer.core.js +88 -40
- package/dist/utils/errorSerializer.factory.d.ts +1 -1
- package/dist/utils/errorSerializer.factory.js +2 -26
- package/dist/utils/errorSerializer.types.d.ts +14 -4
- package/dist/utils/errorUtils.extraction.js +3 -2
- package/dist/utils/errorUtils.transform.d.ts +1 -1
- package/dist/utils/errorUtils.transform.js +2 -26
- package/dist/utils/errorUtils.typeCheck.js +7 -7
- package/package.json +21 -10
- package/dist/.tsbuildinfo +0 -1
- package/dist/base/core/baseError.core.d.ts.map +0 -1
- package/dist/base/core/baseError.core.js.map +0 -1
- package/dist/base/core/errorMetadata.core.d.ts.map +0 -1
- package/dist/base/core/errorMetadata.core.js.map +0 -1
- package/dist/base/core/errorMetadata.type.d.ts.map +0 -1
- package/dist/base/core/errorMetadata.type.js.map +0 -1
- package/dist/base/core/index.d.ts.map +0 -1
- package/dist/base/core/index.js.map +0 -1
- package/dist/base/index.d.ts.map +0 -1
- package/dist/base/index.js.map +0 -1
- package/dist/base/types/baseError.type.d.ts.map +0 -1
- package/dist/base/types/baseError.type.js.map +0 -1
- package/dist/base/types/errorCategory.enum.d.ts.map +0 -1
- package/dist/base/types/errorCategory.enum.js.map +0 -1
- package/dist/base/types/errorCategory.helpers.d.ts.map +0 -1
- package/dist/base/types/errorCategory.helpers.js.map +0 -1
- package/dist/base/types/errorCategory.type.d.ts.map +0 -1
- package/dist/base/types/errorCategory.type.js.map +0 -1
- package/dist/base/types/errorCode.type.d.ts.map +0 -1
- package/dist/base/types/errorCode.type.js.map +0 -1
- package/dist/base/types/errorSeverity.type.d.ts.map +0 -1
- package/dist/base/types/errorSeverity.type.js.map +0 -1
- package/dist/base/types/index.d.ts.map +0 -1
- package/dist/base/types/index.js.map +0 -1
- package/dist/base/utils/baseError.utils.d.ts.map +0 -1
- package/dist/base/utils/baseError.utils.js.map +0 -1
- package/dist/base/utils/index.d.ts.map +0 -1
- package/dist/base/utils/index.js.map +0 -1
- package/dist/domain/access/authentication.error.d.ts.map +0 -1
- package/dist/domain/access/authentication.error.js.map +0 -1
- package/dist/domain/access/authorization.error.d.ts.map +0 -1
- package/dist/domain/access/authorization.error.js.map +0 -1
- package/dist/domain/access/index.d.ts.map +0 -1
- package/dist/domain/access/index.js.map +0 -1
- package/dist/domain/access/rateLimit.error.d.ts.map +0 -1
- package/dist/domain/access/rateLimit.error.js.map +0 -1
- package/dist/domain/api/api.error.d.ts.map +0 -1
- package/dist/domain/api/api.error.js.map +0 -1
- package/dist/domain/api/apiError.base.d.ts.map +0 -1
- package/dist/domain/api/apiError.base.js.map +0 -1
- package/dist/domain/api/apiError.lifecycle.d.ts.map +0 -1
- package/dist/domain/api/apiError.lifecycle.js.map +0 -1
- package/dist/domain/api/apiError.routing.d.ts.map +0 -1
- package/dist/domain/api/apiError.routing.js.map +0 -1
- package/dist/domain/api/index.d.ts.map +0 -1
- package/dist/domain/api/index.js.map +0 -1
- package/dist/domain/app/application.error.d.ts.map +0 -1
- package/dist/domain/app/application.error.js.map +0 -1
- package/dist/domain/app/configuration.error.d.ts.map +0 -1
- package/dist/domain/app/configuration.error.js.map +0 -1
- package/dist/domain/app/domain.error.d.ts.map +0 -1
- package/dist/domain/app/domain.error.js.map +0 -1
- package/dist/domain/app/index.d.ts.map +0 -1
- package/dist/domain/app/index.js.map +0 -1
- package/dist/domain/app/lifecycle.error.d.ts.map +0 -1
- package/dist/domain/app/lifecycle.error.js.map +0 -1
- package/dist/domain/app/lifecycleError.base.d.ts.map +0 -1
- package/dist/domain/app/lifecycleError.base.js.map +0 -1
- package/dist/domain/app/lifecycleError.types.d.ts.map +0 -1
- package/dist/domain/app/lifecycleError.types.js.map +0 -1
- package/dist/domain/app/module.error.d.ts.map +0 -1
- package/dist/domain/app/module.error.js.map +0 -1
- package/dist/domain/app/moduleError.base.d.ts.map +0 -1
- package/dist/domain/app/moduleError.base.js.map +0 -1
- package/dist/domain/app/moduleError.types.d.ts.map +0 -1
- package/dist/domain/app/moduleError.types.js.map +0 -1
- package/dist/domain/body/bodyParser.error.d.ts.map +0 -1
- package/dist/domain/body/bodyParser.error.js.map +0 -1
- package/dist/domain/body/httpBody.error.d.ts.map +0 -1
- package/dist/domain/body/httpBody.error.js.map +0 -1
- package/dist/domain/body/httpBodyError.base.d.ts.map +0 -1
- package/dist/domain/body/httpBodyError.base.js.map +0 -1
- package/dist/domain/body/httpBodyError.types.d.ts.map +0 -1
- package/dist/domain/body/httpBodyError.types.js.map +0 -1
- package/dist/domain/body/httpFormData.error.d.ts.map +0 -1
- package/dist/domain/body/httpFormData.error.js.map +0 -1
- package/dist/domain/body/index.d.ts.map +0 -1
- package/dist/domain/body/index.js.map +0 -1
- package/dist/domain/body/multipart.error.d.ts.map +0 -1
- package/dist/domain/body/multipart.error.js.map +0 -1
- package/dist/domain/documentation/documentation.error.d.ts.map +0 -1
- package/dist/domain/documentation/documentation.error.js.map +0 -1
- package/dist/domain/documentation/documentationError.base.d.ts.map +0 -1
- package/dist/domain/documentation/documentationError.base.js.map +0 -1
- package/dist/domain/documentation/documentationError.types.d.ts.map +0 -1
- package/dist/domain/documentation/documentationError.types.js.map +0 -1
- package/dist/domain/documentation/index.d.ts.map +0 -1
- package/dist/domain/documentation/index.js.map +0 -1
- package/dist/domain/event/event.error.d.ts.map +0 -1
- package/dist/domain/event/event.error.js.map +0 -1
- package/dist/domain/event/eventError.base.d.ts.map +0 -1
- package/dist/domain/event/eventError.base.js.map +0 -1
- package/dist/domain/event/eventError.handler.d.ts.map +0 -1
- package/dist/domain/event/eventError.handler.js.map +0 -1
- package/dist/domain/event/eventError.lifecycle.d.ts.map +0 -1
- package/dist/domain/event/eventError.lifecycle.js.map +0 -1
- package/dist/domain/event/eventError.serialization.d.ts.map +0 -1
- package/dist/domain/event/eventError.serialization.js.map +0 -1
- package/dist/domain/event/index.d.ts.map +0 -1
- package/dist/domain/event/index.js.map +0 -1
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/message/index.d.ts.map +0 -1
- package/dist/domain/message/index.js.map +0 -1
- package/dist/domain/message/message.error.d.ts.map +0 -1
- package/dist/domain/message/message.error.js.map +0 -1
- package/dist/domain/message/messageError.base.d.ts.map +0 -1
- package/dist/domain/message/messageError.base.js.map +0 -1
- package/dist/domain/message/messageError.handler.d.ts.map +0 -1
- package/dist/domain/message/messageError.handler.js.map +0 -1
- package/dist/domain/message/messageError.lifecycle.d.ts.map +0 -1
- package/dist/domain/message/messageError.lifecycle.js.map +0 -1
- package/dist/domain/message/messageError.validation.d.ts.map +0 -1
- package/dist/domain/message/messageError.validation.js.map +0 -1
- package/dist/domain/plugin/index.d.ts.map +0 -1
- package/dist/domain/plugin/index.js.map +0 -1
- package/dist/domain/plugin/plugin.error.d.ts.map +0 -1
- package/dist/domain/plugin/plugin.error.js.map +0 -1
- package/dist/domain/plugin/pluginError.base.d.ts.map +0 -1
- package/dist/domain/plugin/pluginError.base.js.map +0 -1
- package/dist/domain/plugin/pluginError.lifecycle.d.ts.map +0 -1
- package/dist/domain/plugin/pluginError.lifecycle.js.map +0 -1
- package/dist/domain/plugin/pluginError.runtime.d.ts.map +0 -1
- package/dist/domain/plugin/pluginError.runtime.js.map +0 -1
- package/dist/domain/queue/index.d.ts.map +0 -1
- package/dist/domain/queue/index.js.map +0 -1
- package/dist/domain/queue/queue.error.d.ts.map +0 -1
- package/dist/domain/queue/queue.error.js.map +0 -1
- package/dist/domain/queue/queueError.base.d.ts.map +0 -1
- package/dist/domain/queue/queueError.base.js.map +0 -1
- package/dist/domain/queue/queueError.job.d.ts.map +0 -1
- package/dist/domain/queue/queueError.job.js.map +0 -1
- package/dist/domain/queue/queueError.queue.d.ts.map +0 -1
- package/dist/domain/queue/queueError.queue.js.map +0 -1
- package/dist/domain/queue/queueError.worker.d.ts.map +0 -1
- package/dist/domain/queue/queueError.worker.js.map +0 -1
- package/dist/domain/rpc/index.d.ts.map +0 -1
- package/dist/domain/rpc/index.js.map +0 -1
- package/dist/domain/rpc/rpc.error.d.ts.map +0 -1
- package/dist/domain/rpc/rpc.error.js.map +0 -1
- package/dist/domain/rpc/rpcError.base.d.ts.map +0 -1
- package/dist/domain/rpc/rpcError.base.js.map +0 -1
- package/dist/domain/rpc/rpcError.protocol.d.ts.map +0 -1
- package/dist/domain/rpc/rpcError.protocol.js.map +0 -1
- package/dist/domain/rpc/rpcError.transport.d.ts.map +0 -1
- package/dist/domain/rpc/rpcError.transport.js.map +0 -1
- package/dist/domain/scheduler/index.d.ts.map +0 -1
- package/dist/domain/scheduler/index.js.map +0 -1
- package/dist/domain/scheduler/scheduler.error.d.ts.map +0 -1
- package/dist/domain/scheduler/scheduler.error.js.map +0 -1
- package/dist/domain/scheduler/schedulerError.base.d.ts.map +0 -1
- package/dist/domain/scheduler/schedulerError.base.js.map +0 -1
- package/dist/domain/scheduler/schedulerError.execution.d.ts.map +0 -1
- package/dist/domain/scheduler/schedulerError.execution.js.map +0 -1
- package/dist/domain/scheduler/schedulerError.schedule.d.ts.map +0 -1
- package/dist/domain/scheduler/schedulerError.schedule.js.map +0 -1
- package/dist/domain/schema/index.d.ts.map +0 -1
- package/dist/domain/schema/index.js.map +0 -1
- package/dist/domain/schema/schema.error.d.ts.map +0 -1
- package/dist/domain/schema/schema.error.js.map +0 -1
- package/dist/domain/schema/schemaError.base.d.ts.map +0 -1
- package/dist/domain/schema/schemaError.base.js.map +0 -1
- package/dist/domain/schema/schemaError.types.d.ts.map +0 -1
- package/dist/domain/schema/schemaError.types.js.map +0 -1
- package/dist/domain/serialization/index.d.ts.map +0 -1
- package/dist/domain/serialization/index.js.map +0 -1
- package/dist/domain/serialization/serialization.error.d.ts.map +0 -1
- package/dist/domain/serialization/serialization.error.js.map +0 -1
- package/dist/domain/serialization/serializationError.base.d.ts.map +0 -1
- package/dist/domain/serialization/serializationError.base.js.map +0 -1
- package/dist/domain/serialization/serializationError.types.d.ts.map +0 -1
- package/dist/domain/serialization/serializationError.types.js.map +0 -1
- package/dist/domain/state/conflict.error.d.ts.map +0 -1
- package/dist/domain/state/conflict.error.js.map +0 -1
- package/dist/domain/state/index.d.ts.map +0 -1
- package/dist/domain/state/index.js.map +0 -1
- package/dist/domain/state/notFound.error.d.ts.map +0 -1
- package/dist/domain/state/notFound.error.js.map +0 -1
- package/dist/domain/state/validation.error.d.ts.map +0 -1
- package/dist/domain/state/validation.error.js.map +0 -1
- package/dist/domain/state/validationError.base.d.ts.map +0 -1
- package/dist/domain/state/validationError.base.js.map +0 -1
- package/dist/domain/state/validationError.helpers.d.ts.map +0 -1
- package/dist/domain/state/validationError.helpers.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/adapter/adapter.error.d.ts.map +0 -1
- package/dist/infrastructure/adapter/adapter.error.js.map +0 -1
- package/dist/infrastructure/adapter/adapterError.base.d.ts.map +0 -1
- package/dist/infrastructure/adapter/adapterError.base.js.map +0 -1
- package/dist/infrastructure/adapter/adapterError.lifecycle.d.ts.map +0 -1
- package/dist/infrastructure/adapter/adapterError.lifecycle.js.map +0 -1
- package/dist/infrastructure/adapter/adapterError.operation.d.ts.map +0 -1
- package/dist/infrastructure/adapter/adapterError.operation.js.map +0 -1
- package/dist/infrastructure/adapter/index.d.ts.map +0 -1
- package/dist/infrastructure/adapter/index.js.map +0 -1
- package/dist/infrastructure/cache/cache.error.d.ts.map +0 -1
- package/dist/infrastructure/cache/cache.error.js.map +0 -1
- package/dist/infrastructure/cache/cacheError.base.d.ts.map +0 -1
- package/dist/infrastructure/cache/cacheError.base.js.map +0 -1
- package/dist/infrastructure/cache/cacheError.factory.d.ts.map +0 -1
- package/dist/infrastructure/cache/cacheError.factory.js.map +0 -1
- package/dist/infrastructure/cache/index.d.ts.map +0 -1
- package/dist/infrastructure/cache/index.js.map +0 -1
- package/dist/infrastructure/container/container.error.d.ts.map +0 -1
- package/dist/infrastructure/container/container.error.js.map +0 -1
- package/dist/infrastructure/container/containerError.base.d.ts.map +0 -1
- package/dist/infrastructure/container/containerError.base.js.map +0 -1
- package/dist/infrastructure/container/containerError.registration.d.ts.map +0 -1
- package/dist/infrastructure/container/containerError.registration.js.map +0 -1
- package/dist/infrastructure/container/index.d.ts.map +0 -1
- package/dist/infrastructure/container/index.js.map +0 -1
- package/dist/infrastructure/index.d.ts.map +0 -1
- package/dist/infrastructure/index.js.map +0 -1
- package/dist/infrastructure/middleware/index.d.ts.map +0 -1
- package/dist/infrastructure/middleware/index.js.map +0 -1
- package/dist/infrastructure/middleware/middleware.error.d.ts.map +0 -1
- package/dist/infrastructure/middleware/middleware.error.js.map +0 -1
- package/dist/infrastructure/network/http.error.d.ts.map +0 -1
- package/dist/infrastructure/network/http.error.js.map +0 -1
- package/dist/infrastructure/network/httpAdapter.error.d.ts.map +0 -1
- package/dist/infrastructure/network/httpAdapter.error.js.map +0 -1
- package/dist/infrastructure/network/httpClient.errors.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClient.errors.js.map +0 -1
- package/dist/infrastructure/network/httpClientError.advanced.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClientError.advanced.js.map +0 -1
- package/dist/infrastructure/network/httpClientError.base.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClientError.base.js.map +0 -1
- package/dist/infrastructure/network/httpClientError.common.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClientError.common.js.map +0 -1
- package/dist/infrastructure/network/httpClientError.error.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClientError.error.js.map +0 -1
- package/dist/infrastructure/network/httpClientError.options.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClientError.options.js.map +0 -1
- package/dist/infrastructure/network/httpClientError.specialized.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClientError.specialized.js.map +0 -1
- package/dist/infrastructure/network/httpClientError.types.d.ts.map +0 -1
- package/dist/infrastructure/network/httpClientError.types.js.map +0 -1
- package/dist/infrastructure/network/httpError.base.d.ts.map +0 -1
- package/dist/infrastructure/network/httpError.base.js.map +0 -1
- package/dist/infrastructure/network/httpError.helpers.d.ts.map +0 -1
- package/dist/infrastructure/network/httpError.helpers.js.map +0 -1
- package/dist/infrastructure/network/httpResponse.error.d.ts.map +0 -1
- package/dist/infrastructure/network/httpResponse.error.js.map +0 -1
- package/dist/infrastructure/network/httpRouter.error.d.ts.map +0 -1
- package/dist/infrastructure/network/httpRouter.error.js.map +0 -1
- package/dist/infrastructure/network/httpRouterError.base.d.ts.map +0 -1
- package/dist/infrastructure/network/httpRouterError.base.js.map +0 -1
- package/dist/infrastructure/network/httpRouterError.types.d.ts.map +0 -1
- package/dist/infrastructure/network/httpRouterError.types.js.map +0 -1
- package/dist/infrastructure/network/httpServerError.error.d.ts.map +0 -1
- package/dist/infrastructure/network/httpServerError.error.js.map +0 -1
- package/dist/infrastructure/network/httpServerLifecycle.error.d.ts.map +0 -1
- package/dist/infrastructure/network/httpServerLifecycle.error.js.map +0 -1
- package/dist/infrastructure/network/httpServerLifecycleError.base.d.ts.map +0 -1
- package/dist/infrastructure/network/httpServerLifecycleError.base.js.map +0 -1
- package/dist/infrastructure/network/httpServerLifecycleError.types.d.ts.map +0 -1
- package/dist/infrastructure/network/httpServerLifecycleError.types.js.map +0 -1
- package/dist/infrastructure/network/httpStream.error.d.ts.map +0 -1
- package/dist/infrastructure/network/httpStream.error.js.map +0 -1
- package/dist/infrastructure/network/index.d.ts.map +0 -1
- package/dist/infrastructure/network/index.js.map +0 -1
- package/dist/infrastructure/network/network.error.d.ts.map +0 -1
- package/dist/infrastructure/network/network.error.js.map +0 -1
- package/dist/infrastructure/network/networkError.base.d.ts.map +0 -1
- package/dist/infrastructure/network/networkError.base.js.map +0 -1
- package/dist/infrastructure/network/networkError.factory.d.ts.map +0 -1
- package/dist/infrastructure/network/networkError.factory.js.map +0 -1
- package/dist/infrastructure/network/routePattern.error.d.ts.map +0 -1
- package/dist/infrastructure/network/routePattern.error.js.map +0 -1
- package/dist/infrastructure/network/timeout.error.d.ts.map +0 -1
- package/dist/infrastructure/network/timeout.error.js.map +0 -1
- package/dist/infrastructure/network/timeoutError.base.d.ts.map +0 -1
- package/dist/infrastructure/network/timeoutError.base.js.map +0 -1
- package/dist/infrastructure/network/timeoutError.factory.d.ts.map +0 -1
- package/dist/infrastructure/network/timeoutError.factory.js.map +0 -1
- package/dist/infrastructure/service/externalService.error.d.ts.map +0 -1
- package/dist/infrastructure/service/externalService.error.js.map +0 -1
- package/dist/infrastructure/service/externalServiceError.base.d.ts.map +0 -1
- package/dist/infrastructure/service/externalServiceError.base.js.map +0 -1
- package/dist/infrastructure/service/externalServiceError.factory.d.ts.map +0 -1
- package/dist/infrastructure/service/externalServiceError.factory.js.map +0 -1
- package/dist/infrastructure/service/index.d.ts.map +0 -1
- package/dist/infrastructure/service/index.js.map +0 -1
- package/dist/infrastructure/service/service.error.d.ts.map +0 -1
- package/dist/infrastructure/service/service.error.js.map +0 -1
- package/dist/infrastructure/service/serviceError.base.d.ts.map +0 -1
- package/dist/infrastructure/service/serviceError.base.js.map +0 -1
- package/dist/infrastructure/service/serviceError.factory.d.ts.map +0 -1
- package/dist/infrastructure/service/serviceError.factory.js.map +0 -1
- package/dist/infrastructure/storage/database.error.d.ts.map +0 -1
- package/dist/infrastructure/storage/database.error.js.map +0 -1
- package/dist/infrastructure/storage/databaseError.base.d.ts.map +0 -1
- package/dist/infrastructure/storage/databaseError.base.js.map +0 -1
- package/dist/infrastructure/storage/databaseError.factory.d.ts.map +0 -1
- package/dist/infrastructure/storage/databaseError.factory.js.map +0 -1
- package/dist/infrastructure/storage/index.d.ts.map +0 -1
- package/dist/infrastructure/storage/index.js.map +0 -1
- package/dist/infrastructure/storage/storage.error.d.ts.map +0 -1
- package/dist/infrastructure/storage/storage.error.js.map +0 -1
- package/dist/infrastructure/storage/storageError.base.d.ts.map +0 -1
- package/dist/infrastructure/storage/storageError.base.js.map +0 -1
- package/dist/infrastructure/storage/storageError.factory.d.ts.map +0 -1
- package/dist/infrastructure/storage/storageError.factory.js.map +0 -1
- package/dist/system/crypto.error.d.ts.map +0 -1
- package/dist/system/crypto.error.js.map +0 -1
- package/dist/system/cryptoError.base.d.ts.map +0 -1
- package/dist/system/cryptoError.base.js.map +0 -1
- package/dist/system/cryptoError.factory.d.ts.map +0 -1
- package/dist/system/cryptoError.factory.js.map +0 -1
- package/dist/system/index.d.ts.map +0 -1
- package/dist/system/index.js.map +0 -1
- package/dist/system/logging/index.d.ts.map +0 -1
- package/dist/system/logging/index.js.map +0 -1
- package/dist/system/logging/logging.error.d.ts.map +0 -1
- package/dist/system/logging/logging.error.js.map +0 -1
- package/dist/system/runtime.error.d.ts.map +0 -1
- package/dist/system/runtime.error.js.map +0 -1
- package/dist/system/runtimeError.base.d.ts.map +0 -1
- package/dist/system/runtimeError.base.js.map +0 -1
- package/dist/system/runtimeError.types.d.ts.map +0 -1
- package/dist/system/runtimeError.types.js.map +0 -1
- package/dist/system/system.error.d.ts.map +0 -1
- package/dist/system/system.error.js.map +0 -1
- package/dist/system/systemError.base.d.ts.map +0 -1
- package/dist/system/systemError.base.js.map +0 -1
- package/dist/system/systemError.factory.d.ts.map +0 -1
- package/dist/system/systemError.factory.js.map +0 -1
- package/dist/utils/errorHandler.core.d.ts.map +0 -1
- package/dist/utils/errorHandler.core.js.map +0 -1
- package/dist/utils/errorHandler.factory.d.ts.map +0 -1
- package/dist/utils/errorHandler.factory.js.map +0 -1
- package/dist/utils/errorHandler.types.d.ts.map +0 -1
- package/dist/utils/errorHandler.types.js.map +0 -1
- package/dist/utils/errorMapper.core.d.ts.map +0 -1
- package/dist/utils/errorMapper.core.js.map +0 -1
- package/dist/utils/errorMapper.mappers.d.ts.map +0 -1
- package/dist/utils/errorMapper.mappers.js.map +0 -1
- package/dist/utils/errorMapper.registry.d.ts.map +0 -1
- package/dist/utils/errorMapper.registry.js.map +0 -1
- package/dist/utils/errorMapper.types.d.ts.map +0 -1
- package/dist/utils/errorMapper.types.js.map +0 -1
- package/dist/utils/errorSerializer.core.d.ts.map +0 -1
- package/dist/utils/errorSerializer.core.js.map +0 -1
- package/dist/utils/errorSerializer.factory.d.ts.map +0 -1
- package/dist/utils/errorSerializer.factory.js.map +0 -1
- package/dist/utils/errorSerializer.types.d.ts.map +0 -1
- package/dist/utils/errorSerializer.types.js.map +0 -1
- package/dist/utils/errorUtils.extraction.d.ts.map +0 -1
- package/dist/utils/errorUtils.extraction.js.map +0 -1
- package/dist/utils/errorUtils.helper.d.ts.map +0 -1
- package/dist/utils/errorUtils.helper.js.map +0 -1
- package/dist/utils/errorUtils.transform.d.ts.map +0 -1
- package/dist/utils/errorUtils.transform.js.map +0 -1
- package/dist/utils/errorUtils.typeCheck.d.ts.map +0 -1
- package/dist/utils/errorUtils.typeCheck.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
|
@@ -2,52 +2,29 @@
|
|
|
2
2
|
* Error mapping functions — native error mapping, registry-based mapping, rule creation.
|
|
3
3
|
*/
|
|
4
4
|
import { BaseError } from "../base/core/baseError.core.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { isBaseError, normalizeUnknownToBaseError, } from "../base/utils/baseError.utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* Maps common native JavaScript errors.
|
|
8
|
+
*
|
|
9
|
+
* Native `TypeError`/`RangeError`/`SyntaxError` are overwhelmingly programmer
|
|
10
|
+
* bugs rather than client input problems, so they are classified as
|
|
11
|
+
* non-operational internal errors (500, not exposed). Register an explicit
|
|
12
|
+
* mapping rule to treat a specific error type as client input.
|
|
13
|
+
*/
|
|
9
14
|
export function mapNativeError(error) {
|
|
10
|
-
if (error
|
|
15
|
+
if (isBaseError(error)) {
|
|
11
16
|
return error;
|
|
12
17
|
}
|
|
13
|
-
if (error instanceof TypeError) {
|
|
14
|
-
return new BaseError(error.message, {
|
|
15
|
-
code: ErrorCode.INVALID_INPUT,
|
|
16
|
-
category: ErrorCategory.VALIDATION,
|
|
17
|
-
severity: ErrorSeverity.WARNING,
|
|
18
|
-
statusCode: 400,
|
|
19
|
-
expose: true,
|
|
20
|
-
isOperational: true,
|
|
21
|
-
cause: error,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
if (error instanceof RangeError) {
|
|
25
|
-
return new BaseError(error.message, {
|
|
26
|
-
code: ErrorCode.INVALID_INPUT,
|
|
27
|
-
category: ErrorCategory.VALIDATION,
|
|
28
|
-
severity: ErrorSeverity.WARNING,
|
|
29
|
-
statusCode: 400,
|
|
30
|
-
expose: true,
|
|
31
|
-
isOperational: true,
|
|
32
|
-
cause: error,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
18
|
if (error instanceof Error) {
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
category: ErrorCategory.SYSTEM,
|
|
39
|
-
severity: ErrorSeverity.ERROR,
|
|
40
|
-
statusCode: 500,
|
|
41
|
-
expose: false,
|
|
42
|
-
isOperational: false,
|
|
43
|
-
cause: error,
|
|
19
|
+
return normalizeUnknownToBaseError(error, {
|
|
20
|
+
metadata: { nativeErrorName: error.name },
|
|
44
21
|
});
|
|
45
22
|
}
|
|
46
23
|
return undefined;
|
|
47
24
|
}
|
|
48
25
|
/** Maps an error using a registry and falls back to native error mapping. */
|
|
49
26
|
export function mapError(error, registry, context) {
|
|
50
|
-
if (error
|
|
27
|
+
if (isBaseError(error)) {
|
|
51
28
|
return error;
|
|
52
29
|
}
|
|
53
30
|
const mapped = registry?.map(error, context);
|
|
@@ -58,27 +35,58 @@ export function mapError(error, registry, context) {
|
|
|
58
35
|
if (native) {
|
|
59
36
|
return native;
|
|
60
37
|
}
|
|
61
|
-
return
|
|
62
|
-
code: ErrorCode.INTERNAL_ERROR,
|
|
63
|
-
category: ErrorCategory.SYSTEM,
|
|
64
|
-
severity: ErrorSeverity.ERROR,
|
|
65
|
-
statusCode: 500,
|
|
66
|
-
expose: false,
|
|
67
|
-
isOperational: false,
|
|
68
|
-
metadata: { originalType: typeof error },
|
|
69
|
-
});
|
|
38
|
+
return normalizeUnknownToBaseError(error);
|
|
70
39
|
}
|
|
71
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Creates a mapping rule for a specific error constructor.
|
|
42
|
+
*
|
|
43
|
+
* `mapper` may be a function producing a `BaseError`, or a declarative
|
|
44
|
+
* `ErrorMapping` describing the resulting error.
|
|
45
|
+
*/
|
|
72
46
|
export function mapErrorType(name, errorType, mapper, priority = 0) {
|
|
47
|
+
const mapFn = typeof mapper === "function"
|
|
48
|
+
? (error, context) => mapper(error, context)
|
|
49
|
+
: (error, context) => applyErrorMapping(error, mapper, context);
|
|
73
50
|
return {
|
|
74
51
|
name,
|
|
75
52
|
priority,
|
|
76
53
|
predicate: (error) => error instanceof errorType,
|
|
77
|
-
mapper:
|
|
54
|
+
mapper: mapFn,
|
|
78
55
|
};
|
|
79
56
|
}
|
|
80
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Creates a mapping rule based on a predicate.
|
|
59
|
+
*
|
|
60
|
+
* `mapper` may be a function producing a `BaseError`, or a declarative
|
|
61
|
+
* `ErrorMapping` describing the resulting error.
|
|
62
|
+
*/
|
|
81
63
|
export function createErrorMappingRule(name, predicate, mapper, priority = 0) {
|
|
82
|
-
|
|
64
|
+
const mapFn = typeof mapper === "function"
|
|
65
|
+
? mapper
|
|
66
|
+
: (error, context) => applyErrorMapping(error, mapper, context);
|
|
67
|
+
return { name, predicate, mapper: mapFn, priority };
|
|
68
|
+
}
|
|
69
|
+
/** Builds a BaseError from a declarative `ErrorMapping`. */
|
|
70
|
+
export function applyErrorMapping(error, mapping, context) {
|
|
71
|
+
const message = mapping.message ??
|
|
72
|
+
(error instanceof Error && error.message
|
|
73
|
+
? error.message
|
|
74
|
+
: "An unexpected error occurred.");
|
|
75
|
+
return new BaseError(message, {
|
|
76
|
+
code: mapping.code,
|
|
77
|
+
category: mapping.category,
|
|
78
|
+
severity: mapping.severity,
|
|
79
|
+
statusCode: mapping.statusCode,
|
|
80
|
+
expose: mapping.expose,
|
|
81
|
+
isOperational: mapping.isOperational,
|
|
82
|
+
cause: error,
|
|
83
|
+
metadata: {
|
|
84
|
+
...context?.metadata,
|
|
85
|
+
...mapping.metadata,
|
|
86
|
+
...(context?.requestId !== undefined
|
|
87
|
+
? { requestId: context.requestId }
|
|
88
|
+
: {}),
|
|
89
|
+
},
|
|
90
|
+
});
|
|
83
91
|
}
|
|
84
92
|
//# sourceMappingURL=errorMapper.mappers.js.map
|
|
@@ -12,16 +12,35 @@ export declare class ErrorSerializer {
|
|
|
12
12
|
private readonly includeMetadata;
|
|
13
13
|
private readonly safeMessage;
|
|
14
14
|
private readonly redactSensitiveData;
|
|
15
|
+
private readonly sensitiveKeyPattern;
|
|
16
|
+
private readonly publicMetadataKeys;
|
|
15
17
|
constructor(options?: ErrorSerializerOptions);
|
|
16
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Serializes an error for internal logging or monitoring.
|
|
20
|
+
*
|
|
21
|
+
* `includeStack`, `includeCause` and `redactSensitiveData` are applied at
|
|
22
|
+
* every level of the cause chain.
|
|
23
|
+
*/
|
|
17
24
|
serialize(error: BaseError): InternalErrorResponse;
|
|
18
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Serializes an error for an untrusted API client.
|
|
27
|
+
*
|
|
28
|
+
* Never includes a stack or cause. Metadata is only included when the error
|
|
29
|
+
* is exposable (or when `publicMetadataKeys` allow-lists specific keys) and
|
|
30
|
+
* is always redacted.
|
|
31
|
+
*/
|
|
19
32
|
serializePublic(error: BaseError): PublicErrorResponse;
|
|
20
33
|
/** Serializes an unknown thrown value. */
|
|
21
34
|
serializeUnknown(value: unknown): InternalErrorResponse;
|
|
22
35
|
/** Creates a public response from an unknown thrown value. */
|
|
23
36
|
serializeUnknownPublic(value: unknown): PublicErrorResponse;
|
|
24
|
-
/**
|
|
37
|
+
/** Applies the serializer options to one level of a serialized error. */
|
|
38
|
+
private serializeLevel;
|
|
39
|
+
/** Applies the serializer options recursively to a serialized cause. */
|
|
40
|
+
private serializeCause;
|
|
41
|
+
/** Computes the metadata allowed in a public response. */
|
|
42
|
+
private publicMetadata;
|
|
43
|
+
/** Removes commonly sensitive metadata fields (recursively). */
|
|
25
44
|
private redactMetadata;
|
|
26
45
|
}
|
|
27
46
|
//# sourceMappingURL=errorSerializer.core.d.ts.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Converts errors into safe, predictable serialized structures.
|
|
3
3
|
*/
|
|
4
4
|
import { BaseError } from "../base/core/baseError.core.js";
|
|
5
|
+
import { pickErrorMetadata, redactErrorMetadata, } from "../base/core/errorMetadata.core.js";
|
|
5
6
|
import { normalizeUnknownError } from "./errorSerializer.factory.js";
|
|
6
7
|
export { createErrorSerializer, serializeError, serializePublicError, normalizeUnknownError, } from "./errorSerializer.factory.js";
|
|
7
8
|
/** Converts errors into safe, predictable serialized structures. */
|
|
@@ -11,41 +12,41 @@ export class ErrorSerializer {
|
|
|
11
12
|
includeMetadata;
|
|
12
13
|
safeMessage;
|
|
13
14
|
redactSensitiveData;
|
|
15
|
+
sensitiveKeyPattern;
|
|
16
|
+
publicMetadataKeys;
|
|
14
17
|
constructor(options = {}) {
|
|
15
18
|
this.includeStack = options.includeStack ?? false;
|
|
16
19
|
this.includeCause = options.includeCause ?? false;
|
|
17
20
|
this.includeMetadata = options.includeMetadata ?? true;
|
|
18
21
|
this.safeMessage = options.safeMessage ?? "An unexpected error occurred.";
|
|
19
22
|
this.redactSensitiveData = options.redactSensitiveData ?? true;
|
|
23
|
+
this.sensitiveKeyPattern = options.sensitiveKeyPattern;
|
|
24
|
+
this.publicMetadataKeys = options.publicMetadataKeys;
|
|
20
25
|
}
|
|
21
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Serializes an error for internal logging or monitoring.
|
|
28
|
+
*
|
|
29
|
+
* `includeStack`, `includeCause` and `redactSensitiveData` are applied at
|
|
30
|
+
* every level of the cause chain.
|
|
31
|
+
*/
|
|
22
32
|
serialize(error) {
|
|
23
|
-
|
|
24
|
-
const result = {
|
|
25
|
-
...serialized,
|
|
26
|
-
...(this.includeStack ? {} : { stack: undefined }),
|
|
27
|
-
...(this.includeCause ? {} : { cause: undefined }),
|
|
28
|
-
...(this.includeMetadata ? {} : { metadata: {} }),
|
|
29
|
-
};
|
|
30
|
-
if (this.redactSensitiveData && result.metadata) {
|
|
31
|
-
return {
|
|
32
|
-
...result,
|
|
33
|
-
metadata: this.redactMetadata(result.metadata),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
33
|
+
return this.serializeLevel(error.toJSON());
|
|
37
34
|
}
|
|
38
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Serializes an error for an untrusted API client.
|
|
37
|
+
*
|
|
38
|
+
* Never includes a stack or cause. Metadata is only included when the error
|
|
39
|
+
* is exposable (or when `publicMetadataKeys` allow-lists specific keys) and
|
|
40
|
+
* is always redacted.
|
|
41
|
+
*/
|
|
39
42
|
serializePublic(error) {
|
|
40
|
-
const metadata = this.
|
|
41
|
-
? this.redactMetadata(error.metadata)
|
|
42
|
-
: undefined;
|
|
43
|
+
const metadata = this.publicMetadata(error);
|
|
43
44
|
return {
|
|
44
45
|
code: error.code,
|
|
45
46
|
message: error.expose ? error.message : this.safeMessage,
|
|
46
47
|
category: error.category,
|
|
47
48
|
statusCode: error.statusCode,
|
|
48
|
-
...(metadata
|
|
49
|
+
...(metadata !== undefined ? { metadata } : {}),
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
/** Serializes an unknown thrown value. */
|
|
@@ -56,27 +57,74 @@ export class ErrorSerializer {
|
|
|
56
57
|
serializeUnknownPublic(value) {
|
|
57
58
|
return this.serializePublic(normalizeUnknownError(value));
|
|
58
59
|
}
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
]);
|
|
75
|
-
const result = {};
|
|
76
|
-
for (const [key, value] of Object.entries(metadata)) {
|
|
77
|
-
result[key] = sensitiveKeys.has(key) ? "[REDACTED]" : value;
|
|
78
|
-
}
|
|
60
|
+
/** Applies the serializer options to one level of a serialized error. */
|
|
61
|
+
serializeLevel(serialized) {
|
|
62
|
+
const { stack, cause, metadata, ...rest } = serialized;
|
|
63
|
+
const result = {
|
|
64
|
+
...rest,
|
|
65
|
+
metadata: this.includeMetadata
|
|
66
|
+
? this.redactSensitiveData
|
|
67
|
+
? this.redactMetadata(metadata)
|
|
68
|
+
: metadata
|
|
69
|
+
: {},
|
|
70
|
+
...(this.includeStack && stack !== undefined ? { stack } : {}),
|
|
71
|
+
...(this.includeCause && cause !== undefined
|
|
72
|
+
? { cause: this.serializeCause(cause) }
|
|
73
|
+
: {}),
|
|
74
|
+
};
|
|
79
75
|
return result;
|
|
80
76
|
}
|
|
77
|
+
/** Applies the serializer options recursively to a serialized cause. */
|
|
78
|
+
serializeCause(cause) {
|
|
79
|
+
if (cause === null || typeof cause !== "object")
|
|
80
|
+
return cause;
|
|
81
|
+
if (Array.isArray(cause))
|
|
82
|
+
return cause;
|
|
83
|
+
const record = cause;
|
|
84
|
+
if (isSerializedBaseError(record)) {
|
|
85
|
+
return this.serializeLevel(record);
|
|
86
|
+
}
|
|
87
|
+
// Native error shape: { name, message, stack?, cause? }
|
|
88
|
+
const { stack, cause: nested, ...rest } = record;
|
|
89
|
+
return {
|
|
90
|
+
...rest,
|
|
91
|
+
...(this.includeStack && stack !== undefined ? { stack } : {}),
|
|
92
|
+
...(nested !== undefined ? { cause: this.serializeCause(nested) } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Computes the metadata allowed in a public response. */
|
|
96
|
+
publicMetadata(error) {
|
|
97
|
+
if (!this.includeMetadata)
|
|
98
|
+
return undefined;
|
|
99
|
+
let metadata;
|
|
100
|
+
if (this.publicMetadataKeys !== undefined) {
|
|
101
|
+
metadata = pickErrorMetadata(error.metadata, this.publicMetadataKeys);
|
|
102
|
+
}
|
|
103
|
+
else if (error.expose) {
|
|
104
|
+
metadata = error.metadata;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const redacted = this.redactSensitiveData
|
|
110
|
+
? this.redactMetadata(metadata)
|
|
111
|
+
: metadata;
|
|
112
|
+
return Object.keys(redacted).length > 0 ? redacted : undefined;
|
|
113
|
+
}
|
|
114
|
+
/** Removes commonly sensitive metadata fields (recursively). */
|
|
115
|
+
redactMetadata(metadata) {
|
|
116
|
+
return redactErrorMetadata(metadata, {
|
|
117
|
+
sensitiveKeyPattern: this.sensitiveKeyPattern,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Structural check for a serialized BaseError (used on nested causes). */
|
|
122
|
+
function isSerializedBaseError(value) {
|
|
123
|
+
return (typeof value.code === "string" &&
|
|
124
|
+
typeof value.category === "string" &&
|
|
125
|
+
typeof value.severity === "string" &&
|
|
126
|
+
typeof value.statusCode === "number" &&
|
|
127
|
+
typeof value.metadata === "object" &&
|
|
128
|
+
value.metadata !== null);
|
|
81
129
|
}
|
|
82
130
|
//# sourceMappingURL=errorSerializer.core.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error serializer factory and utility functions.
|
|
3
3
|
*/
|
|
4
|
-
import { BaseError } from "../base/core/baseError.core.js";
|
|
4
|
+
import type { BaseError } from "../base/core/baseError.core.js";
|
|
5
5
|
import { ErrorSerializer } from "./errorSerializer.core.js";
|
|
6
6
|
import type { ErrorSerializerOptions, PublicErrorResponse, InternalErrorResponse } from "./errorSerializer.types.js";
|
|
7
7
|
export type { ErrorSerializerOptions, PublicErrorResponse, InternalErrorResponse, } from "./errorSerializer.types.js";
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error serializer factory and utility functions.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { ErrorCategory } from "../base/types/errorCategory.type.js";
|
|
6
|
-
import { ErrorSeverity } from "../base/types/errorSeverity.type.js";
|
|
4
|
+
import { normalizeUnknownToBaseError } from "../base/utils/baseError.utils.js";
|
|
7
5
|
import { ErrorSerializer } from "./errorSerializer.core.js";
|
|
8
6
|
/** Creates an ErrorSerializer instance. */
|
|
9
7
|
export function createErrorSerializer(options = {}) {
|
|
@@ -19,28 +17,6 @@ export function serializePublicError(error, options = {}) {
|
|
|
19
17
|
}
|
|
20
18
|
/** Converts an unknown thrown value into a BaseError. */
|
|
21
19
|
export function normalizeUnknownError(value) {
|
|
22
|
-
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
if (value instanceof Error) {
|
|
26
|
-
return new BaseError(value.message || "An unexpected error occurred.", {
|
|
27
|
-
code: "INTERNAL_ERROR",
|
|
28
|
-
category: ErrorCategory.SYSTEM,
|
|
29
|
-
severity: ErrorSeverity.ERROR,
|
|
30
|
-
statusCode: 500,
|
|
31
|
-
expose: false,
|
|
32
|
-
isOperational: false,
|
|
33
|
-
cause: value,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return new BaseError("An unexpected error occurred.", {
|
|
37
|
-
code: "INTERNAL_ERROR",
|
|
38
|
-
category: ErrorCategory.SYSTEM,
|
|
39
|
-
severity: ErrorSeverity.ERROR,
|
|
40
|
-
statusCode: 500,
|
|
41
|
-
expose: false,
|
|
42
|
-
isOperational: false,
|
|
43
|
-
metadata: { originalType: typeof value },
|
|
44
|
-
});
|
|
20
|
+
return normalizeUnknownToBaseError(value);
|
|
45
21
|
}
|
|
46
22
|
//# sourceMappingURL=errorSerializer.factory.js.map
|
|
@@ -5,16 +5,26 @@ import type { SerializedBaseError } from "../base/types/baseError.type.js";
|
|
|
5
5
|
import { ErrorCategory } from "../base/types/errorCategory.type.js";
|
|
6
6
|
/** Options controlling error serialization. */
|
|
7
7
|
export interface ErrorSerializerOptions {
|
|
8
|
-
/** Include the stack trace
|
|
8
|
+
/** Include the stack trace (at every level of the cause chain). Defaults to false. */
|
|
9
9
|
readonly includeStack?: boolean;
|
|
10
|
-
/** Include the error cause. Defaults to false. */
|
|
10
|
+
/** Include the error cause chain. Defaults to false. */
|
|
11
11
|
readonly includeCause?: boolean;
|
|
12
|
-
/** Include internal
|
|
12
|
+
/** Include metadata in internal serialization. Defaults to true. */
|
|
13
13
|
readonly includeMetadata?: boolean;
|
|
14
14
|
/** Replace non-exposable error messages with a safe message. */
|
|
15
15
|
readonly safeMessage?: string;
|
|
16
|
-
/**
|
|
16
|
+
/** Redact sensitive metadata values (recursively, at every level). Defaults to true. */
|
|
17
17
|
readonly redactSensitiveData?: boolean;
|
|
18
|
+
/** Pattern used to detect sensitive metadata keys. Defaults to the package pattern. */
|
|
19
|
+
readonly sensitiveKeyPattern?: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Metadata keys allowed in public output.
|
|
22
|
+
*
|
|
23
|
+
* When provided, only these keys are copied into `PublicErrorResponse.metadata`
|
|
24
|
+
* (for exposed and non-exposed errors alike). When omitted, metadata is only
|
|
25
|
+
* included for errors with `expose: true`, and never for non-exposed errors.
|
|
26
|
+
*/
|
|
27
|
+
readonly publicMetadataKeys?: readonly string[];
|
|
18
28
|
}
|
|
19
29
|
/** Public error representation suitable for an API response. */
|
|
20
30
|
export interface PublicErrorResponse {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error extraction utilities — message, name, stack, root cause.
|
|
3
3
|
*/
|
|
4
|
+
import { isBaseError } from "../base/utils/baseError.utils.js";
|
|
4
5
|
import { BaseError } from "../base/core/baseError.core.js";
|
|
5
6
|
import { isErrorLike } from "./errorUtils.typeCheck.js";
|
|
6
7
|
/** Returns the message from an unknown thrown value. */
|
|
@@ -56,7 +57,7 @@ export function getRootBaseError(value) {
|
|
|
56
57
|
const visited = new Set();
|
|
57
58
|
while (current !== undefined && current !== null && !visited.has(current)) {
|
|
58
59
|
visited.add(current);
|
|
59
|
-
if (current
|
|
60
|
+
if (isBaseError(current)) {
|
|
60
61
|
result = current;
|
|
61
62
|
}
|
|
62
63
|
if (current instanceof Error && "cause" in current) {
|
|
@@ -77,7 +78,7 @@ export function getErrorDiagnostics(value) {
|
|
|
77
78
|
if (stack !== undefined) {
|
|
78
79
|
diagnostics.stack = stack;
|
|
79
80
|
}
|
|
80
|
-
if (value
|
|
81
|
+
if (isBaseError(value)) {
|
|
81
82
|
diagnostics.code = value.code;
|
|
82
83
|
diagnostics.category = value.category;
|
|
83
84
|
diagnostics.severity = value.severity;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error transformation utilities — toError, withErrorContext, tryCatch, normalize.
|
|
3
3
|
*/
|
|
4
|
-
import { BaseError } from "../base/core/baseError.core.js";
|
|
4
|
+
import type { BaseError } from "../base/core/baseError.core.js";
|
|
5
5
|
/** Safely converts an unknown thrown value into an Error instance. */
|
|
6
6
|
export declare function toError(value: unknown, fallback?: string): Error;
|
|
7
7
|
/** Adds context to an Error while preserving the original error as its cause. */
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error transformation utilities — toError, withErrorContext, tryCatch, normalize.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { ErrorCategory } from "../base/types/errorCategory.type.js";
|
|
6
|
-
import { ErrorSeverity } from "../base/types/errorSeverity.type.js";
|
|
4
|
+
import { normalizeUnknownToBaseError } from "../base/utils/baseError.utils.js";
|
|
7
5
|
import { getErrorMessage } from "./errorUtils.extraction.js";
|
|
8
6
|
/** Safely converts an unknown thrown value into an Error instance. */
|
|
9
7
|
export function toError(value, fallback = "An unexpected error occurred.") {
|
|
@@ -37,28 +35,6 @@ export async function tryCatchAsync(operation) {
|
|
|
37
35
|
}
|
|
38
36
|
/** Converts an unknown thrown value into a BaseError. */
|
|
39
37
|
export function normalizeToBaseError(value) {
|
|
40
|
-
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
if (value instanceof Error) {
|
|
44
|
-
return new BaseError(value.message || "An unexpected error occurred.", {
|
|
45
|
-
code: "INTERNAL_ERROR",
|
|
46
|
-
category: ErrorCategory.SYSTEM,
|
|
47
|
-
severity: ErrorSeverity.ERROR,
|
|
48
|
-
statusCode: 500,
|
|
49
|
-
expose: false,
|
|
50
|
-
isOperational: false,
|
|
51
|
-
cause: value,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return new BaseError(getErrorMessage(value), {
|
|
55
|
-
code: "INTERNAL_ERROR",
|
|
56
|
-
category: ErrorCategory.SYSTEM,
|
|
57
|
-
severity: ErrorSeverity.ERROR,
|
|
58
|
-
statusCode: 500,
|
|
59
|
-
expose: false,
|
|
60
|
-
isOperational: false,
|
|
61
|
-
metadata: { originalType: typeof value },
|
|
62
|
-
});
|
|
38
|
+
return normalizeUnknownToBaseError(value);
|
|
63
39
|
}
|
|
64
40
|
//# sourceMappingURL=errorUtils.transform.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error type-checking utilities.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { isBaseError } from "../base/utils/baseError.utils.js";
|
|
5
5
|
import { ErrorCategory } from "../base/types/errorCategory.type.js";
|
|
6
6
|
import { ErrorSeverity } from "../base/types/errorSeverity.type.js";
|
|
7
7
|
/** Type guard for unknown error-like values. */
|
|
@@ -13,31 +13,31 @@ export function isErrorLike(value) {
|
|
|
13
13
|
}
|
|
14
14
|
/** Returns whether an error is operational. */
|
|
15
15
|
export function isOperationalError(value) {
|
|
16
|
-
return value
|
|
16
|
+
return isBaseError(value) && value.isOperational;
|
|
17
17
|
}
|
|
18
18
|
/** Returns whether an error is safe to expose to clients. */
|
|
19
19
|
export function isExposableError(value) {
|
|
20
|
-
return value
|
|
20
|
+
return isBaseError(value) && value.expose;
|
|
21
21
|
}
|
|
22
22
|
/** Returns whether an error represents a server-side failure. */
|
|
23
23
|
export function isServerError(value) {
|
|
24
|
-
if (value
|
|
24
|
+
if (isBaseError(value)) {
|
|
25
25
|
return value.statusCode >= 500;
|
|
26
26
|
}
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
/** Returns whether an error represents a client-side failure. */
|
|
30
30
|
export function isClientError(value) {
|
|
31
|
-
return (value
|
|
31
|
+
return (isBaseError(value) &&
|
|
32
32
|
value.statusCode >= 400 &&
|
|
33
33
|
value.statusCode < 500);
|
|
34
34
|
}
|
|
35
35
|
/** Returns whether an error belongs to a category. */
|
|
36
36
|
export function hasErrorCategory(value, category) {
|
|
37
|
-
return value
|
|
37
|
+
return isBaseError(value) && value.category === category;
|
|
38
38
|
}
|
|
39
39
|
/** Returns whether an error has a specific severity. */
|
|
40
40
|
export function hasErrorSeverity(value, severity) {
|
|
41
|
-
return value
|
|
41
|
+
return isBaseError(value) && value.severity === severity;
|
|
42
42
|
}
|
|
43
43
|
//# sourceMappingURL=errorUtils.typeCheck.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/errors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Shared error base class, error codes, and error handling utilities for the Zudojs framework.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/**/*.map",
|
|
18
|
+
"!dist/**/*.tsbuildinfo",
|
|
19
|
+
"!dist/.tsbuildinfo"
|
|
17
20
|
],
|
|
18
|
-
"
|
|
19
|
-
"build": "tsc -p tsconfig.json",
|
|
20
|
-
"clean": "rm -rf dist",
|
|
21
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
22
|
-
},
|
|
21
|
+
"sideEffects": false,
|
|
23
22
|
"dependencies": {},
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"typescript": "
|
|
24
|
+
"typescript": "7.0.2",
|
|
25
|
+
"vitest": "^4.1.11"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=24.0.0"
|
|
@@ -37,8 +37,19 @@
|
|
|
37
37
|
"error-handling"
|
|
38
38
|
],
|
|
39
39
|
"homepage": "https://github.com/oyinlola-tech/zudo#readme",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/oyinlola-tech/zudo/issues"
|
|
42
|
+
},
|
|
40
43
|
"repository": {
|
|
41
44
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/oyinlola-tech/zudo"
|
|
45
|
+
"url": "https://github.com/oyinlola-tech/zudo",
|
|
46
|
+
"directory": "packages/errors"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.json",
|
|
50
|
+
"clean": "rm -rf dist",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:watch": "vitest"
|
|
43
54
|
}
|
|
44
|
-
}
|
|
55
|
+
}
|