@zudojs/errors 0.1.1 → 1.0.1
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 +292 -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 +144 -39
- 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 +25 -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
|
@@ -61,20 +61,17 @@ export function createExternalServiceError(service, message = "An external servi
|
|
|
61
61
|
export function isExternalServiceError(value) {
|
|
62
62
|
return value instanceof ExternalServiceError;
|
|
63
63
|
}
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Maps a remote response status into an appropriate local HTTP status.
|
|
66
|
+
*
|
|
67
|
+
* An upstream failure is our problem, not our caller's: every upstream status
|
|
68
|
+
* maps to 502 Bad Gateway except 429, which is passed through so that callers
|
|
69
|
+
* can back off. Pass an explicit `statusCode` option to override.
|
|
70
|
+
*/
|
|
71
|
+
export function mapResponseStatus(responseStatus) {
|
|
72
72
|
if (responseStatus === 429) {
|
|
73
73
|
return 429;
|
|
74
74
|
}
|
|
75
|
-
if (responseStatus >= 400) {
|
|
76
|
-
return responseStatus;
|
|
77
|
-
}
|
|
78
75
|
return 502;
|
|
79
76
|
}
|
|
80
77
|
//# sourceMappingURL=externalServiceError.base.js.map
|
|
@@ -5,5 +5,7 @@ import { ExternalServiceError } from "./externalServiceError.base.js";
|
|
|
5
5
|
/** Creates an external service timeout error. */
|
|
6
6
|
export declare function externalServiceTimeoutError(service: string, operation?: string): ExternalServiceError;
|
|
7
7
|
/** Creates an external service unavailable error. */
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function externalServiceUnavailableError(service: string, operation?: string): ExternalServiceError;
|
|
9
|
+
/** @deprecated Use `externalServiceUnavailableError`. */
|
|
10
|
+
export declare const externalServiceUnavailable: typeof externalServiceUnavailableError;
|
|
9
11
|
//# sourceMappingURL=externalServiceError.factory.d.ts.map
|
|
@@ -18,7 +18,7 @@ export function externalServiceTimeoutError(service, operation) {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
/** Creates an external service unavailable error. */
|
|
21
|
-
export function
|
|
21
|
+
export function externalServiceUnavailableError(service, operation) {
|
|
22
22
|
return new ExternalServiceError(`${service} is currently unavailable.`, {
|
|
23
23
|
service,
|
|
24
24
|
operation,
|
|
@@ -29,4 +29,6 @@ export function externalServiceUnavailable(service, operation) {
|
|
|
29
29
|
expose: false,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
/** @deprecated Use `externalServiceUnavailableError`. */
|
|
33
|
+
export const externalServiceUnavailable = externalServiceUnavailableError;
|
|
32
34
|
//# sourceMappingURL=externalServiceError.factory.js.map
|
|
@@ -31,7 +31,7 @@ export function databaseTransactionError(message = "The database transaction fai
|
|
|
31
31
|
export function databaseMigrationError(message = "The database migration failed.", options = {}) {
|
|
32
32
|
return new DatabaseError(message, {
|
|
33
33
|
...options,
|
|
34
|
-
code: ErrorCode.
|
|
34
|
+
code: ErrorCode.DATABASE_MIGRATION,
|
|
35
35
|
operation: DatabaseOperation.MIGRATION,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Storage error factory functions.
|
|
3
3
|
*/
|
|
4
4
|
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
5
|
-
import { StorageError, StorageOperation
|
|
5
|
+
import { StorageError, StorageOperation } from "./storageError.base.js";
|
|
6
6
|
/** Creates a storage read error. */
|
|
7
7
|
export function storageReadError(resource, provider, cause) {
|
|
8
8
|
return new StorageError(`Failed to read "${resource}".`, {
|
|
@@ -56,7 +56,7 @@ export function storageDeleteError(resource, provider, cause) {
|
|
|
56
56
|
/** Creates a storage not found error. */
|
|
57
57
|
export function storageNotFoundError(resource, provider) {
|
|
58
58
|
return new StorageError(`Resource "${resource}" was not found.`, {
|
|
59
|
-
code: ErrorCode.
|
|
59
|
+
code: ErrorCode.STORAGE_NOT_FOUND,
|
|
60
60
|
operation: StorageOperation.READ,
|
|
61
61
|
provider,
|
|
62
62
|
resource,
|
|
@@ -20,8 +20,11 @@ export function cryptoCipherError(message = "Cryptographic encryption or decrypt
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
/** Creates a cryptographic signature error. */
|
|
23
|
-
export function cryptoSignatureError(message
|
|
24
|
-
|
|
23
|
+
export function cryptoSignatureError(message, operation = CryptoOperation.VERIFY_SIGNATURE, algorithm) {
|
|
24
|
+
const defaultMessage = operation === CryptoOperation.SIGN
|
|
25
|
+
? "Cryptographic signing failed."
|
|
26
|
+
: "Cryptographic signature verification failed.";
|
|
27
|
+
return new CryptoError(message ?? defaultMessage, {
|
|
25
28
|
code: ErrorCode.CRYPTO_SIGNATURE,
|
|
26
29
|
operation,
|
|
27
30
|
algorithm,
|
|
@@ -11,7 +11,7 @@ export class RuntimeError extends BaseError {
|
|
|
11
11
|
constructor(message, options = {}) {
|
|
12
12
|
super(message, {
|
|
13
13
|
...options,
|
|
14
|
-
code: options.code ?? ErrorCode.
|
|
14
|
+
code: options.code ?? ErrorCode.RUNTIME,
|
|
15
15
|
category: options.category ?? ErrorCategory.RUNTIME,
|
|
16
16
|
severity: options.severity ?? ErrorSeverity.ERROR,
|
|
17
17
|
statusCode: options.statusCode ?? 500,
|
|
@@ -1,30 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized error normalization, serialization, and reporting service.
|
|
3
3
|
*/
|
|
4
|
-
import { BaseError } from "../base/core/baseError.core.js";
|
|
5
|
-
import type { ErrorHandlerOptions, ErrorHandlerResult, ErrorHandlerContext, NormalizedError } from "./errorHandler.types.js";
|
|
6
|
-
export type { ErrorHandlerOptions, ErrorHandlerResult, ErrorHandlerContext, ErrorReporter, NormalizedError, } from "./errorHandler.types.js";
|
|
4
|
+
import type { BaseError } from "../base/core/baseError.core.js";
|
|
5
|
+
import type { ErrorHandlerOptions, ErrorHandlerResult, ErrorHandlerContext, NormalizedError, PublicErrorHandlerResult } from "./errorHandler.types.js";
|
|
6
|
+
export type { ErrorHandlerOptions, ErrorHandlerResult, ErrorHandlerContext, ErrorReporter, ErrorReporterFailureHandler, NormalizedError, PublicErrorHandlerResult, } from "./errorHandler.types.js";
|
|
7
7
|
export { createErrorHandler, normalizeError, isHandledError, } from "./errorHandler.factory.js";
|
|
8
8
|
/** Centralized error normalization, serialization, and reporting service. */
|
|
9
9
|
export declare class ErrorHandler {
|
|
10
10
|
private readonly reporter?;
|
|
11
|
+
private readonly onReporterError?;
|
|
11
12
|
private readonly defaultStatusCode;
|
|
12
13
|
private readonly defaultMessage;
|
|
13
14
|
private readonly includeStack;
|
|
15
|
+
private readonly publicMetadataKeys;
|
|
16
|
+
private readonly sensitiveKeyPattern;
|
|
14
17
|
constructor(options?: ErrorHandlerOptions);
|
|
15
18
|
/** Converts an unknown thrown value into a BaseError. */
|
|
16
19
|
normalize(value: unknown): NormalizedError;
|
|
17
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Handles and normalizes an unknown error.
|
|
22
|
+
*
|
|
23
|
+
* The reporter is isolated: if it throws or rejects, the failure is passed
|
|
24
|
+
* to `onReporterError` (or swallowed) and the original error's result is
|
|
25
|
+
* still returned.
|
|
26
|
+
*/
|
|
18
27
|
handle(value: unknown, context?: ErrorHandlerContext): Promise<ErrorHandlerResult>;
|
|
19
|
-
/**
|
|
28
|
+
/** Handles an unknown error and returns the client-safe representation. */
|
|
29
|
+
handlePublic(value: unknown, context?: ErrorHandlerContext): Promise<PublicErrorHandlerResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Converts a BaseError into the internal result object.
|
|
32
|
+
*
|
|
33
|
+
* Metadata is redacted recursively; the stack is never included.
|
|
34
|
+
*/
|
|
20
35
|
toResult(error: BaseError, context?: ErrorHandlerContext): ErrorHandlerResult;
|
|
36
|
+
/**
|
|
37
|
+
* Converts a BaseError into a client-safe result.
|
|
38
|
+
*
|
|
39
|
+
* Only `code`, `message`, `statusCode`, request/correlation ids and
|
|
40
|
+
* allow-listed metadata (`details`) are included. Internal classification
|
|
41
|
+
* fields and non-exposed metadata are never revealed.
|
|
42
|
+
*/
|
|
43
|
+
toPublicResult(error: BaseError, context?: ErrorHandlerContext): PublicErrorHandlerResult;
|
|
21
44
|
/** Reports an error without producing a response. */
|
|
22
45
|
report(value: unknown, context?: ErrorHandlerContext): Promise<BaseError>;
|
|
23
46
|
/** Determines whether an error should expose its message to clients. */
|
|
24
47
|
shouldExpose(error: BaseError): boolean;
|
|
25
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Returns a safe serialized error representation (never includes a stack).
|
|
50
|
+
*
|
|
51
|
+
* Equivalent to `toPublicResult`; kept for backwards compatibility.
|
|
52
|
+
*/
|
|
26
53
|
serialize(error: BaseError, context?: ErrorHandlerContext): Record<string, unknown>;
|
|
27
|
-
/**
|
|
28
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Returns the full internal representation for logging, including the
|
|
56
|
+
* (redacted) cause chain and, when `includeStack` is enabled, stack traces.
|
|
57
|
+
*/
|
|
58
|
+
toLogObject(error: BaseError, context?: ErrorHandlerContext): Record<string, unknown>;
|
|
59
|
+
/** Invokes the reporter without letting its failure escape. */
|
|
60
|
+
private reportSafely;
|
|
61
|
+
/** Removes obviously sensitive fields from metadata (recursively). */
|
|
62
|
+
private redact;
|
|
29
63
|
}
|
|
30
64
|
//# sourceMappingURL=errorHandler.core.d.ts.map
|
|
@@ -1,67 +1,70 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized error normalization, serialization, and reporting service.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { ErrorSeverity } from "../base/types/errorSeverity.type.js";
|
|
4
|
+
import { pickErrorMetadata, redactErrorMetadata, serializeErrorMetadata, } from "../base/core/errorMetadata.core.js";
|
|
5
|
+
import { isBaseError, normalizeUnknownToBaseError, } from "../base/utils/baseError.utils.js";
|
|
6
|
+
import { ErrorSerializer } from "./errorSerializer.core.js";
|
|
8
7
|
export { createErrorHandler, normalizeError, isHandledError, } from "./errorHandler.factory.js";
|
|
9
8
|
/** Centralized error normalization, serialization, and reporting service. */
|
|
10
9
|
export class ErrorHandler {
|
|
11
10
|
reporter;
|
|
11
|
+
onReporterError;
|
|
12
12
|
defaultStatusCode;
|
|
13
13
|
defaultMessage;
|
|
14
14
|
includeStack;
|
|
15
|
+
publicMetadataKeys;
|
|
16
|
+
sensitiveKeyPattern;
|
|
15
17
|
constructor(options = {}) {
|
|
16
18
|
this.reporter = options.reporter;
|
|
19
|
+
this.onReporterError = options.onReporterError;
|
|
17
20
|
this.defaultStatusCode = options.defaultStatusCode ?? 500;
|
|
18
21
|
this.defaultMessage =
|
|
19
22
|
options.defaultMessage ?? "An unexpected error occurred.";
|
|
20
23
|
this.includeStack = options.includeStack ?? false;
|
|
24
|
+
this.publicMetadataKeys = options.publicMetadataKeys;
|
|
25
|
+
this.sensitiveKeyPattern = options.sensitiveKeyPattern;
|
|
21
26
|
}
|
|
22
27
|
/** Converts an unknown thrown value into a BaseError. */
|
|
23
28
|
normalize(value) {
|
|
24
|
-
if (value
|
|
29
|
+
if (isBaseError(value)) {
|
|
25
30
|
return { error: value, original: value };
|
|
26
31
|
}
|
|
27
|
-
|
|
28
|
-
const error = new BaseError(value.message || this.defaultMessage, {
|
|
29
|
-
code: ErrorCode.INTERNAL_ERROR,
|
|
30
|
-
category: ErrorCategory.SYSTEM,
|
|
31
|
-
severity: ErrorSeverity.ERROR,
|
|
32
|
-
statusCode: this.defaultStatusCode,
|
|
33
|
-
expose: false,
|
|
34
|
-
isOperational: false,
|
|
35
|
-
cause: value,
|
|
36
|
-
});
|
|
37
|
-
return { error, original: value };
|
|
38
|
-
}
|
|
39
|
-
const message = typeof value === "string" ? value : this.defaultMessage;
|
|
40
|
-
const error = new BaseError(message, {
|
|
41
|
-
code: ErrorCode.INTERNAL_ERROR,
|
|
42
|
-
category: ErrorCategory.SYSTEM,
|
|
43
|
-
severity: ErrorSeverity.ERROR,
|
|
32
|
+
const error = normalizeUnknownToBaseError(value, {
|
|
44
33
|
statusCode: this.defaultStatusCode,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
...(value instanceof Error || typeof value === "string"
|
|
35
|
+
? {}
|
|
36
|
+
: { message: this.defaultMessage }),
|
|
48
37
|
});
|
|
49
38
|
return { error, original: value };
|
|
50
39
|
}
|
|
51
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Handles and normalizes an unknown error.
|
|
42
|
+
*
|
|
43
|
+
* The reporter is isolated: if it throws or rejects, the failure is passed
|
|
44
|
+
* to `onReporterError` (or swallowed) and the original error's result is
|
|
45
|
+
* still returned.
|
|
46
|
+
*/
|
|
52
47
|
async handle(value, context) {
|
|
53
48
|
const { error } = this.normalize(value);
|
|
54
|
-
|
|
55
|
-
await this.reporter(error, context);
|
|
56
|
-
}
|
|
49
|
+
await this.reportSafely(error, context);
|
|
57
50
|
return this.toResult(error, context);
|
|
58
51
|
}
|
|
59
|
-
/**
|
|
52
|
+
/** Handles an unknown error and returns the client-safe representation. */
|
|
53
|
+
async handlePublic(value, context) {
|
|
54
|
+
const { error } = this.normalize(value);
|
|
55
|
+
await this.reportSafely(error, context);
|
|
56
|
+
return this.toPublicResult(error, context);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Converts a BaseError into the internal result object.
|
|
60
|
+
*
|
|
61
|
+
* Metadata is redacted recursively; the stack is never included.
|
|
62
|
+
*/
|
|
60
63
|
toResult(error, context) {
|
|
61
|
-
const metadata = {
|
|
62
|
-
...(error.
|
|
64
|
+
const metadata = this.redact({
|
|
65
|
+
...serializeErrorMetadata(error.metadata),
|
|
63
66
|
...(context?.metadata ?? {}),
|
|
64
|
-
};
|
|
67
|
+
});
|
|
65
68
|
return {
|
|
66
69
|
code: error.code,
|
|
67
70
|
message: error.expose ? error.message : this.defaultMessage,
|
|
@@ -74,51 +77,101 @@ export class ErrorHandler {
|
|
|
74
77
|
...(context?.correlationId
|
|
75
78
|
? { correlationId: context.correlationId }
|
|
76
79
|
: {}),
|
|
77
|
-
...(Object.keys(metadata).length > 0
|
|
78
|
-
|
|
80
|
+
...(Object.keys(metadata).length > 0 ? { metadata } : {}),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Converts a BaseError into a client-safe result.
|
|
85
|
+
*
|
|
86
|
+
* Only `code`, `message`, `statusCode`, request/correlation ids and
|
|
87
|
+
* allow-listed metadata (`details`) are included. Internal classification
|
|
88
|
+
* fields and non-exposed metadata are never revealed.
|
|
89
|
+
*/
|
|
90
|
+
toPublicResult(error, context) {
|
|
91
|
+
let details;
|
|
92
|
+
if (this.publicMetadataKeys !== undefined) {
|
|
93
|
+
details = this.redact(pickErrorMetadata(error.metadata, this.publicMetadataKeys));
|
|
94
|
+
}
|
|
95
|
+
else if (error.expose) {
|
|
96
|
+
details = this.redact(error.metadata);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
code: error.code,
|
|
100
|
+
message: error.expose ? error.message : this.defaultMessage,
|
|
101
|
+
statusCode: error.statusCode,
|
|
102
|
+
...(context?.requestId ? { requestId: context.requestId } : {}),
|
|
103
|
+
...(context?.correlationId
|
|
104
|
+
? { correlationId: context.correlationId }
|
|
105
|
+
: {}),
|
|
106
|
+
...(details !== undefined && Object.keys(details).length > 0
|
|
107
|
+
? { details }
|
|
79
108
|
: {}),
|
|
80
109
|
};
|
|
81
110
|
}
|
|
82
111
|
/** Reports an error without producing a response. */
|
|
83
112
|
async report(value, context) {
|
|
84
113
|
const { error } = this.normalize(value);
|
|
85
|
-
|
|
86
|
-
await this.reporter(error, context);
|
|
87
|
-
}
|
|
114
|
+
await this.reportSafely(error, context);
|
|
88
115
|
return error;
|
|
89
116
|
}
|
|
90
117
|
/** Determines whether an error should expose its message to clients. */
|
|
91
118
|
shouldExpose(error) {
|
|
92
119
|
return error.expose;
|
|
93
120
|
}
|
|
94
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Returns a safe serialized error representation (never includes a stack).
|
|
123
|
+
*
|
|
124
|
+
* Equivalent to `toPublicResult`; kept for backwards compatibility.
|
|
125
|
+
*/
|
|
95
126
|
serialize(error, context) {
|
|
96
|
-
|
|
97
|
-
if (this.includeStack && error.expose === false) {
|
|
98
|
-
return { ...result, stack: error.stack };
|
|
99
|
-
}
|
|
100
|
-
return result;
|
|
127
|
+
return this.toPublicResult(error, context);
|
|
101
128
|
}
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Returns the full internal representation for logging, including the
|
|
131
|
+
* (redacted) cause chain and, when `includeStack` is enabled, stack traces.
|
|
132
|
+
*/
|
|
133
|
+
toLogObject(error, context) {
|
|
134
|
+
const serialized = new ErrorSerializer({
|
|
135
|
+
includeStack: this.includeStack,
|
|
136
|
+
includeCause: true,
|
|
137
|
+
includeMetadata: true,
|
|
138
|
+
redactSensitiveData: true,
|
|
139
|
+
sensitiveKeyPattern: this.sensitiveKeyPattern,
|
|
140
|
+
}).serialize(error);
|
|
141
|
+
return {
|
|
142
|
+
...serialized,
|
|
143
|
+
...(context?.requestId ? { requestId: context.requestId } : {}),
|
|
144
|
+
...(context?.correlationId
|
|
145
|
+
? { correlationId: context.correlationId }
|
|
146
|
+
: {}),
|
|
147
|
+
...(context?.metadata
|
|
148
|
+
? { context: this.redact(context.metadata) }
|
|
149
|
+
: {}),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** Invokes the reporter without letting its failure escape. */
|
|
153
|
+
async reportSafely(error, context) {
|
|
154
|
+
if (!this.reporter)
|
|
155
|
+
return;
|
|
156
|
+
try {
|
|
157
|
+
await this.reporter(error, context);
|
|
158
|
+
}
|
|
159
|
+
catch (reporterError) {
|
|
160
|
+
if (this.onReporterError) {
|
|
161
|
+
try {
|
|
162
|
+
this.onReporterError(reporterError, error, context);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// A failing failure-handler must never break error handling.
|
|
166
|
+
}
|
|
167
|
+
}
|
|
120
168
|
}
|
|
121
|
-
|
|
169
|
+
}
|
|
170
|
+
/** Removes obviously sensitive fields from metadata (recursively). */
|
|
171
|
+
redact(metadata) {
|
|
172
|
+
return redactErrorMetadata(metadata, {
|
|
173
|
+
sensitiveKeyPattern: this.sensitiveKeyPattern,
|
|
174
|
+
});
|
|
122
175
|
}
|
|
123
176
|
}
|
|
124
177
|
//# sourceMappingURL=errorHandler.core.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error handler factory 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 { ErrorHandler } from "./errorHandler.core.js";
|
|
6
6
|
import type { ErrorHandlerOptions } from "./errorHandler.types.js";
|
|
7
7
|
/** Creates a default error handler. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error handler factory functions.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { isBaseError } from "../base/utils/baseError.utils.js";
|
|
5
5
|
import { ErrorHandler } from "./errorHandler.core.js";
|
|
6
6
|
/** Creates a default error handler. */
|
|
7
7
|
export function createErrorHandler(options = {}) {
|
|
@@ -13,6 +13,6 @@ export function normalizeError(value) {
|
|
|
13
13
|
}
|
|
14
14
|
/** Determines whether an unknown value is a supported BaseError. */
|
|
15
15
|
export function isHandledError(value) {
|
|
16
|
-
return value
|
|
16
|
+
return isBaseError(value);
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=errorHandler.factory.js.map
|
|
@@ -18,7 +18,13 @@ export interface NormalizedError {
|
|
|
18
18
|
readonly error: BaseError;
|
|
19
19
|
readonly original: unknown;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Structured result returned by the error handler.
|
|
23
|
+
*
|
|
24
|
+
* This is the INTERNAL representation (classification fields and redacted
|
|
25
|
+
* metadata included); use `ErrorHandler.toPublicResult` / `PublicErrorHandlerResult`
|
|
26
|
+
* for anything returned to an untrusted client.
|
|
27
|
+
*/
|
|
22
28
|
export interface ErrorHandlerResult {
|
|
23
29
|
readonly code: string;
|
|
24
30
|
readonly message: string;
|
|
@@ -31,13 +37,43 @@ export interface ErrorHandlerResult {
|
|
|
31
37
|
readonly correlationId?: string;
|
|
32
38
|
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
33
39
|
}
|
|
40
|
+
/** Client-safe result returned by `ErrorHandler.toPublicResult`. */
|
|
41
|
+
export interface PublicErrorHandlerResult {
|
|
42
|
+
readonly code: string;
|
|
43
|
+
readonly message: string;
|
|
44
|
+
readonly statusCode: number;
|
|
45
|
+
readonly requestId?: string;
|
|
46
|
+
readonly correlationId?: string;
|
|
47
|
+
/** Allow-listed, redacted metadata (see `ErrorHandlerOptions.publicMetadataKeys`). */
|
|
48
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
49
|
+
}
|
|
34
50
|
/** Callback used to report errors to an external logger or monitoring system. */
|
|
35
51
|
export type ErrorReporter = (error: BaseError, context?: ErrorHandlerContext) => void | Promise<void>;
|
|
52
|
+
/** Callback invoked when the reporter itself fails. */
|
|
53
|
+
export type ErrorReporterFailureHandler = (reporterError: unknown, originalError: BaseError, context?: ErrorHandlerContext) => void;
|
|
36
54
|
/** Options for constructing an ErrorHandler. */
|
|
37
55
|
export interface ErrorHandlerOptions {
|
|
38
56
|
readonly reporter?: ErrorReporter;
|
|
57
|
+
/**
|
|
58
|
+
* Invoked when `reporter` throws or rejects. Reporter failures never
|
|
59
|
+
* propagate out of `handle`/`report`; when this hook is absent they are
|
|
60
|
+
* swallowed.
|
|
61
|
+
*/
|
|
62
|
+
readonly onReporterError?: ErrorReporterFailureHandler;
|
|
39
63
|
readonly defaultStatusCode?: number;
|
|
40
64
|
readonly defaultMessage?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Include the stack trace in `toLogObject` output. Stacks are never
|
|
67
|
+
* included in `toResult`, `toPublicResult` or `serialize`.
|
|
68
|
+
*/
|
|
41
69
|
readonly includeStack?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Metadata keys copied into `PublicErrorHandlerResult.details`. When omitted,
|
|
72
|
+
* exposed errors contribute their (redacted) metadata and non-exposed errors
|
|
73
|
+
* contribute nothing.
|
|
74
|
+
*/
|
|
75
|
+
readonly publicMetadataKeys?: readonly string[];
|
|
76
|
+
/** Pattern used to detect sensitive metadata keys. */
|
|
77
|
+
readonly sensitiveKeyPattern?: RegExp;
|
|
42
78
|
}
|
|
43
79
|
//# sourceMappingURL=errorHandler.types.d.ts.map
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type { ErrorMapperContext, ErrorMapping, ErrorMapperPredicate, ErrorMapper, ErrorMappingRule, } from "./errorMapper.types.js";
|
|
5
5
|
export { ErrorMapperRegistry, createErrorMapperRegistry, } from "./errorMapper.registry.js";
|
|
6
|
-
export { mapNativeError, mapError, mapErrorType, createErrorMappingRule, } from "./errorMapper.mappers.js";
|
|
6
|
+
export { mapNativeError, mapError, mapErrorType, createErrorMappingRule, applyErrorMapping, type ErrorConstructor, } from "./errorMapper.mappers.js";
|
|
7
7
|
//# sourceMappingURL=errorMapper.core.d.ts.map
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Error mapper — re-exports from focused files.
|
|
3
3
|
*/
|
|
4
4
|
export { ErrorMapperRegistry, createErrorMapperRegistry, } from "./errorMapper.registry.js";
|
|
5
|
-
export { mapNativeError, mapError, mapErrorType, createErrorMappingRule, } from "./errorMapper.mappers.js";
|
|
5
|
+
export { mapNativeError, mapError, mapErrorType, createErrorMappingRule, applyErrorMapping, } from "./errorMapper.mappers.js";
|
|
6
6
|
//# sourceMappingURL=errorMapper.core.js.map
|
|
@@ -2,14 +2,35 @@
|
|
|
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 type { ErrorMapperContext, ErrorMapper, ErrorMapperPredicate, ErrorMappingRule } from "./errorMapper.types.js";
|
|
5
|
+
import type { ErrorMapperContext, ErrorMapper, ErrorMapperPredicate, ErrorMapping, ErrorMappingRule } from "./errorMapper.types.js";
|
|
6
6
|
import type { ErrorMapperRegistry } from "./errorMapper.registry.js";
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Maps common native JavaScript errors.
|
|
9
|
+
*
|
|
10
|
+
* Native `TypeError`/`RangeError`/`SyntaxError` are overwhelmingly programmer
|
|
11
|
+
* bugs rather than client input problems, so they are classified as
|
|
12
|
+
* non-operational internal errors (500, not exposed). Register an explicit
|
|
13
|
+
* mapping rule to treat a specific error type as client input.
|
|
14
|
+
*/
|
|
8
15
|
export declare function mapNativeError(error: unknown): BaseError | undefined;
|
|
9
16
|
/** Maps an error using a registry and falls back to native error mapping. */
|
|
10
17
|
export declare function mapError(error: unknown, registry?: ErrorMapperRegistry, context?: ErrorMapperContext): BaseError;
|
|
11
|
-
/**
|
|
12
|
-
export
|
|
13
|
-
/**
|
|
14
|
-
|
|
18
|
+
/** Any constructor whose instances are `T` (parameters are not constrained). */
|
|
19
|
+
export type ErrorConstructor<T extends Error> = abstract new (...args: any[]) => T;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a mapping rule for a specific error constructor.
|
|
22
|
+
*
|
|
23
|
+
* `mapper` may be a function producing a `BaseError`, or a declarative
|
|
24
|
+
* `ErrorMapping` describing the resulting error.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mapErrorType<T extends Error>(name: string, errorType: ErrorConstructor<T>, mapper: ((error: T, context?: ErrorMapperContext) => BaseError) | ErrorMapping, priority?: number): ErrorMappingRule;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a mapping rule based on a predicate.
|
|
29
|
+
*
|
|
30
|
+
* `mapper` may be a function producing a `BaseError`, or a declarative
|
|
31
|
+
* `ErrorMapping` describing the resulting error.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createErrorMappingRule(name: string, predicate: ErrorMapperPredicate, mapper: ErrorMapper | ErrorMapping, priority?: number): ErrorMappingRule;
|
|
34
|
+
/** Builds a BaseError from a declarative `ErrorMapping`. */
|
|
35
|
+
export declare function applyErrorMapping(error: unknown, mapping: ErrorMapping, context?: ErrorMapperContext): BaseError;
|
|
15
36
|
//# sourceMappingURL=errorMapper.mappers.d.ts.map
|