@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.
Files changed (506) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -8
  3. package/dist/base/core/baseError.core.d.ts +25 -2
  4. package/dist/base/core/baseError.core.js +95 -23
  5. package/dist/base/core/errorMetadata.core.d.ts +62 -5
  6. package/dist/base/core/errorMetadata.core.js +292 -23
  7. package/dist/base/types/errorCategory.helpers.js +3 -2
  8. package/dist/base/types/errorCode.type.d.ts +70 -1
  9. package/dist/base/types/errorCode.type.js +78 -2
  10. package/dist/base/types/errorSeverity.type.js +3 -2
  11. package/dist/base/utils/baseError.utils.d.ts +18 -2
  12. package/dist/base/utils/baseError.utils.js +68 -17
  13. package/dist/domain/access/rateLimit.error.d.ts +6 -1
  14. package/dist/domain/access/rateLimit.error.js +7 -9
  15. package/dist/domain/api/apiError.base.js +2 -2
  16. package/dist/domain/api/apiError.lifecycle.d.ts +10 -1
  17. package/dist/domain/api/apiError.lifecycle.js +22 -7
  18. package/dist/domain/api/apiError.routing.js +4 -4
  19. package/dist/domain/app/domain.error.d.ts +2 -0
  20. package/dist/domain/app/domain.error.js +3 -1
  21. package/dist/domain/app/lifecycleError.types.js +2 -8
  22. package/dist/domain/app/moduleError.types.d.ts +3 -0
  23. package/dist/domain/app/moduleError.types.js +6 -2
  24. package/dist/domain/body/bodyParser.error.d.ts +9 -2
  25. package/dist/domain/body/bodyParser.error.js +20 -12
  26. package/dist/domain/body/httpBodyError.base.js +1 -2
  27. package/dist/domain/body/httpBodyError.types.js +1 -3
  28. package/dist/domain/body/httpFormData.error.js +2 -4
  29. package/dist/domain/body/multipart.error.js +2 -4
  30. package/dist/domain/documentation/documentationError.base.js +4 -2
  31. package/dist/domain/documentation/documentationError.types.js +1 -11
  32. package/dist/domain/documentation/index.d.ts +1 -1
  33. package/dist/domain/documentation/index.js +1 -1
  34. package/dist/domain/event/event.error.d.ts +1 -1
  35. package/dist/domain/event/event.error.js +1 -1
  36. package/dist/domain/event/eventError.base.d.ts +4 -1
  37. package/dist/domain/event/eventError.base.js +7 -9
  38. package/dist/domain/event/eventError.handler.d.ts +12 -3
  39. package/dist/domain/event/eventError.handler.js +21 -11
  40. package/dist/domain/event/eventError.lifecycle.d.ts +20 -3
  41. package/dist/domain/event/eventError.lifecycle.js +48 -18
  42. package/dist/domain/event/eventError.serialization.d.ts +10 -2
  43. package/dist/domain/event/eventError.serialization.js +16 -4
  44. package/dist/domain/message/message.error.d.ts +1 -0
  45. package/dist/domain/message/message.error.js +1 -0
  46. package/dist/domain/message/messageError.base.d.ts +4 -1
  47. package/dist/domain/message/messageError.base.js +7 -9
  48. package/dist/domain/message/messageError.handler.d.ts +12 -3
  49. package/dist/domain/message/messageError.handler.js +22 -12
  50. package/dist/domain/message/messageError.lifecycle.d.ts +5 -1
  51. package/dist/domain/message/messageError.lifecycle.js +15 -8
  52. package/dist/domain/message/messageError.serialization.d.ts +26 -0
  53. package/dist/domain/message/messageError.serialization.js +35 -0
  54. package/dist/domain/plugin/pluginError.lifecycle.js +23 -21
  55. package/dist/domain/plugin/pluginError.runtime.d.ts +5 -1
  56. package/dist/domain/plugin/pluginError.runtime.js +12 -7
  57. package/dist/domain/queue/queueError.base.d.ts +19 -0
  58. package/dist/domain/queue/queueError.base.js +24 -4
  59. package/dist/domain/queue/queueError.job.js +2 -0
  60. package/dist/domain/queue/queueError.worker.d.ts +9 -3
  61. package/dist/domain/queue/queueError.worker.js +14 -6
  62. package/dist/domain/rpc/rpcError.base.js +0 -2
  63. package/dist/domain/rpc/rpcError.protocol.js +0 -7
  64. package/dist/domain/rpc/rpcError.transport.d.ts +10 -1
  65. package/dist/domain/rpc/rpcError.transport.js +19 -9
  66. package/dist/domain/scheduler/schedulerError.base.d.ts +17 -3
  67. package/dist/domain/scheduler/schedulerError.base.js +26 -15
  68. package/dist/domain/scheduler/schedulerError.execution.d.ts +7 -6
  69. package/dist/domain/scheduler/schedulerError.execution.js +22 -18
  70. package/dist/domain/scheduler/schedulerError.schedule.d.ts +15 -5
  71. package/dist/domain/scheduler/schedulerError.schedule.js +32 -14
  72. package/dist/domain/schema/index.d.ts +2 -1
  73. package/dist/domain/schema/index.js +1 -1
  74. package/dist/domain/schema/schemaError.base.d.ts +31 -5
  75. package/dist/domain/schema/schemaError.base.js +34 -6
  76. package/dist/domain/schema/schemaError.types.js +12 -5
  77. package/dist/domain/serialization/serializationError.base.d.ts +8 -2
  78. package/dist/domain/serialization/serializationError.base.js +38 -8
  79. package/dist/domain/serialization/serializationError.types.d.ts +22 -3
  80. package/dist/domain/serialization/serializationError.types.js +30 -5
  81. package/dist/domain/shared/domainError.helpers.d.ts +60 -0
  82. package/dist/domain/shared/domainError.helpers.js +191 -0
  83. package/dist/domain/state/conflict.error.d.ts +1 -1
  84. package/dist/domain/state/conflict.error.js +2 -2
  85. package/dist/domain/state/validationError.base.d.ts +8 -1
  86. package/dist/domain/state/validationError.base.js +11 -2
  87. package/dist/infrastructure/adapter/adapterError.base.js +6 -6
  88. package/dist/infrastructure/adapter/adapterError.lifecycle.js +0 -3
  89. package/dist/infrastructure/adapter/adapterError.operation.js +0 -5
  90. package/dist/infrastructure/cache/cacheError.base.js +1 -1
  91. package/dist/infrastructure/container/containerError.registration.js +6 -4
  92. package/dist/infrastructure/network/httpAdapter.error.js +4 -2
  93. package/dist/infrastructure/network/httpClientError.advanced.js +10 -18
  94. package/dist/infrastructure/network/httpClientError.base.d.ts +11 -0
  95. package/dist/infrastructure/network/httpClientError.base.js +47 -7
  96. package/dist/infrastructure/network/httpClientError.common.d.ts +14 -0
  97. package/dist/infrastructure/network/httpClientError.common.js +21 -31
  98. package/dist/infrastructure/network/httpClientError.specialized.js +5 -8
  99. package/dist/infrastructure/network/httpClientError.types.d.ts +23 -2
  100. package/dist/infrastructure/network/httpClientError.types.js +55 -42
  101. package/dist/infrastructure/network/httpResponse.error.js +0 -3
  102. package/dist/infrastructure/network/httpRouterError.base.js +0 -1
  103. package/dist/infrastructure/network/httpRouterError.types.d.ts +5 -3
  104. package/dist/infrastructure/network/httpRouterError.types.js +6 -7
  105. package/dist/infrastructure/network/httpServerError.error.js +6 -10
  106. package/dist/infrastructure/network/httpServerLifecycleError.base.js +0 -1
  107. package/dist/infrastructure/network/httpServerLifecycleError.types.js +0 -3
  108. package/dist/infrastructure/network/httpStream.error.js +0 -1
  109. package/dist/infrastructure/network/network.error.d.ts +1 -1
  110. package/dist/infrastructure/network/network.error.js +1 -1
  111. package/dist/infrastructure/network/networkError.factory.d.ts +9 -2
  112. package/dist/infrastructure/network/networkError.factory.js +9 -2
  113. package/dist/infrastructure/network/routePattern.error.d.ts +7 -6
  114. package/dist/infrastructure/network/routePattern.error.js +16 -8
  115. package/dist/infrastructure/network/timeoutError.base.d.ts +7 -0
  116. package/dist/infrastructure/network/timeoutError.base.js +12 -1
  117. package/dist/infrastructure/network/timeoutError.factory.d.ts +14 -0
  118. package/dist/infrastructure/network/timeoutError.factory.js +25 -17
  119. package/dist/infrastructure/service/externalService.error.d.ts +1 -1
  120. package/dist/infrastructure/service/externalService.error.js +1 -1
  121. package/dist/infrastructure/service/externalServiceError.base.d.ts +8 -0
  122. package/dist/infrastructure/service/externalServiceError.base.js +8 -11
  123. package/dist/infrastructure/service/externalServiceError.factory.d.ts +3 -1
  124. package/dist/infrastructure/service/externalServiceError.factory.js +3 -1
  125. package/dist/infrastructure/storage/databaseError.factory.js +1 -1
  126. package/dist/infrastructure/storage/storageError.factory.js +2 -2
  127. package/dist/system/cryptoError.factory.js +5 -2
  128. package/dist/system/runtimeError.base.js +1 -1
  129. package/dist/utils/errorHandler.core.d.ts +42 -8
  130. package/dist/utils/errorHandler.core.js +116 -63
  131. package/dist/utils/errorHandler.factory.d.ts +1 -1
  132. package/dist/utils/errorHandler.factory.js +2 -2
  133. package/dist/utils/errorHandler.types.d.ts +37 -1
  134. package/dist/utils/errorMapper.core.d.ts +1 -1
  135. package/dist/utils/errorMapper.core.js +1 -1
  136. package/dist/utils/errorMapper.mappers.d.ts +27 -6
  137. package/dist/utils/errorMapper.mappers.js +57 -49
  138. package/dist/utils/errorSerializer.core.d.ts +22 -3
  139. package/dist/utils/errorSerializer.core.js +144 -39
  140. package/dist/utils/errorSerializer.factory.d.ts +1 -1
  141. package/dist/utils/errorSerializer.factory.js +2 -26
  142. package/dist/utils/errorSerializer.types.d.ts +14 -4
  143. package/dist/utils/errorUtils.extraction.js +3 -2
  144. package/dist/utils/errorUtils.transform.d.ts +1 -1
  145. package/dist/utils/errorUtils.transform.js +2 -26
  146. package/dist/utils/errorUtils.typeCheck.js +7 -7
  147. package/package.json +25 -10
  148. package/dist/.tsbuildinfo +0 -1
  149. package/dist/base/core/baseError.core.d.ts.map +0 -1
  150. package/dist/base/core/baseError.core.js.map +0 -1
  151. package/dist/base/core/errorMetadata.core.d.ts.map +0 -1
  152. package/dist/base/core/errorMetadata.core.js.map +0 -1
  153. package/dist/base/core/errorMetadata.type.d.ts.map +0 -1
  154. package/dist/base/core/errorMetadata.type.js.map +0 -1
  155. package/dist/base/core/index.d.ts.map +0 -1
  156. package/dist/base/core/index.js.map +0 -1
  157. package/dist/base/index.d.ts.map +0 -1
  158. package/dist/base/index.js.map +0 -1
  159. package/dist/base/types/baseError.type.d.ts.map +0 -1
  160. package/dist/base/types/baseError.type.js.map +0 -1
  161. package/dist/base/types/errorCategory.enum.d.ts.map +0 -1
  162. package/dist/base/types/errorCategory.enum.js.map +0 -1
  163. package/dist/base/types/errorCategory.helpers.d.ts.map +0 -1
  164. package/dist/base/types/errorCategory.helpers.js.map +0 -1
  165. package/dist/base/types/errorCategory.type.d.ts.map +0 -1
  166. package/dist/base/types/errorCategory.type.js.map +0 -1
  167. package/dist/base/types/errorCode.type.d.ts.map +0 -1
  168. package/dist/base/types/errorCode.type.js.map +0 -1
  169. package/dist/base/types/errorSeverity.type.d.ts.map +0 -1
  170. package/dist/base/types/errorSeverity.type.js.map +0 -1
  171. package/dist/base/types/index.d.ts.map +0 -1
  172. package/dist/base/types/index.js.map +0 -1
  173. package/dist/base/utils/baseError.utils.d.ts.map +0 -1
  174. package/dist/base/utils/baseError.utils.js.map +0 -1
  175. package/dist/base/utils/index.d.ts.map +0 -1
  176. package/dist/base/utils/index.js.map +0 -1
  177. package/dist/domain/access/authentication.error.d.ts.map +0 -1
  178. package/dist/domain/access/authentication.error.js.map +0 -1
  179. package/dist/domain/access/authorization.error.d.ts.map +0 -1
  180. package/dist/domain/access/authorization.error.js.map +0 -1
  181. package/dist/domain/access/index.d.ts.map +0 -1
  182. package/dist/domain/access/index.js.map +0 -1
  183. package/dist/domain/access/rateLimit.error.d.ts.map +0 -1
  184. package/dist/domain/access/rateLimit.error.js.map +0 -1
  185. package/dist/domain/api/api.error.d.ts.map +0 -1
  186. package/dist/domain/api/api.error.js.map +0 -1
  187. package/dist/domain/api/apiError.base.d.ts.map +0 -1
  188. package/dist/domain/api/apiError.base.js.map +0 -1
  189. package/dist/domain/api/apiError.lifecycle.d.ts.map +0 -1
  190. package/dist/domain/api/apiError.lifecycle.js.map +0 -1
  191. package/dist/domain/api/apiError.routing.d.ts.map +0 -1
  192. package/dist/domain/api/apiError.routing.js.map +0 -1
  193. package/dist/domain/api/index.d.ts.map +0 -1
  194. package/dist/domain/api/index.js.map +0 -1
  195. package/dist/domain/app/application.error.d.ts.map +0 -1
  196. package/dist/domain/app/application.error.js.map +0 -1
  197. package/dist/domain/app/configuration.error.d.ts.map +0 -1
  198. package/dist/domain/app/configuration.error.js.map +0 -1
  199. package/dist/domain/app/domain.error.d.ts.map +0 -1
  200. package/dist/domain/app/domain.error.js.map +0 -1
  201. package/dist/domain/app/index.d.ts.map +0 -1
  202. package/dist/domain/app/index.js.map +0 -1
  203. package/dist/domain/app/lifecycle.error.d.ts.map +0 -1
  204. package/dist/domain/app/lifecycle.error.js.map +0 -1
  205. package/dist/domain/app/lifecycleError.base.d.ts.map +0 -1
  206. package/dist/domain/app/lifecycleError.base.js.map +0 -1
  207. package/dist/domain/app/lifecycleError.types.d.ts.map +0 -1
  208. package/dist/domain/app/lifecycleError.types.js.map +0 -1
  209. package/dist/domain/app/module.error.d.ts.map +0 -1
  210. package/dist/domain/app/module.error.js.map +0 -1
  211. package/dist/domain/app/moduleError.base.d.ts.map +0 -1
  212. package/dist/domain/app/moduleError.base.js.map +0 -1
  213. package/dist/domain/app/moduleError.types.d.ts.map +0 -1
  214. package/dist/domain/app/moduleError.types.js.map +0 -1
  215. package/dist/domain/body/bodyParser.error.d.ts.map +0 -1
  216. package/dist/domain/body/bodyParser.error.js.map +0 -1
  217. package/dist/domain/body/httpBody.error.d.ts.map +0 -1
  218. package/dist/domain/body/httpBody.error.js.map +0 -1
  219. package/dist/domain/body/httpBodyError.base.d.ts.map +0 -1
  220. package/dist/domain/body/httpBodyError.base.js.map +0 -1
  221. package/dist/domain/body/httpBodyError.types.d.ts.map +0 -1
  222. package/dist/domain/body/httpBodyError.types.js.map +0 -1
  223. package/dist/domain/body/httpFormData.error.d.ts.map +0 -1
  224. package/dist/domain/body/httpFormData.error.js.map +0 -1
  225. package/dist/domain/body/index.d.ts.map +0 -1
  226. package/dist/domain/body/index.js.map +0 -1
  227. package/dist/domain/body/multipart.error.d.ts.map +0 -1
  228. package/dist/domain/body/multipart.error.js.map +0 -1
  229. package/dist/domain/documentation/documentation.error.d.ts.map +0 -1
  230. package/dist/domain/documentation/documentation.error.js.map +0 -1
  231. package/dist/domain/documentation/documentationError.base.d.ts.map +0 -1
  232. package/dist/domain/documentation/documentationError.base.js.map +0 -1
  233. package/dist/domain/documentation/documentationError.types.d.ts.map +0 -1
  234. package/dist/domain/documentation/documentationError.types.js.map +0 -1
  235. package/dist/domain/documentation/index.d.ts.map +0 -1
  236. package/dist/domain/documentation/index.js.map +0 -1
  237. package/dist/domain/event/event.error.d.ts.map +0 -1
  238. package/dist/domain/event/event.error.js.map +0 -1
  239. package/dist/domain/event/eventError.base.d.ts.map +0 -1
  240. package/dist/domain/event/eventError.base.js.map +0 -1
  241. package/dist/domain/event/eventError.handler.d.ts.map +0 -1
  242. package/dist/domain/event/eventError.handler.js.map +0 -1
  243. package/dist/domain/event/eventError.lifecycle.d.ts.map +0 -1
  244. package/dist/domain/event/eventError.lifecycle.js.map +0 -1
  245. package/dist/domain/event/eventError.serialization.d.ts.map +0 -1
  246. package/dist/domain/event/eventError.serialization.js.map +0 -1
  247. package/dist/domain/event/index.d.ts.map +0 -1
  248. package/dist/domain/event/index.js.map +0 -1
  249. package/dist/domain/index.d.ts.map +0 -1
  250. package/dist/domain/index.js.map +0 -1
  251. package/dist/domain/message/index.d.ts.map +0 -1
  252. package/dist/domain/message/index.js.map +0 -1
  253. package/dist/domain/message/message.error.d.ts.map +0 -1
  254. package/dist/domain/message/message.error.js.map +0 -1
  255. package/dist/domain/message/messageError.base.d.ts.map +0 -1
  256. package/dist/domain/message/messageError.base.js.map +0 -1
  257. package/dist/domain/message/messageError.handler.d.ts.map +0 -1
  258. package/dist/domain/message/messageError.handler.js.map +0 -1
  259. package/dist/domain/message/messageError.lifecycle.d.ts.map +0 -1
  260. package/dist/domain/message/messageError.lifecycle.js.map +0 -1
  261. package/dist/domain/message/messageError.validation.d.ts.map +0 -1
  262. package/dist/domain/message/messageError.validation.js.map +0 -1
  263. package/dist/domain/plugin/index.d.ts.map +0 -1
  264. package/dist/domain/plugin/index.js.map +0 -1
  265. package/dist/domain/plugin/plugin.error.d.ts.map +0 -1
  266. package/dist/domain/plugin/plugin.error.js.map +0 -1
  267. package/dist/domain/plugin/pluginError.base.d.ts.map +0 -1
  268. package/dist/domain/plugin/pluginError.base.js.map +0 -1
  269. package/dist/domain/plugin/pluginError.lifecycle.d.ts.map +0 -1
  270. package/dist/domain/plugin/pluginError.lifecycle.js.map +0 -1
  271. package/dist/domain/plugin/pluginError.runtime.d.ts.map +0 -1
  272. package/dist/domain/plugin/pluginError.runtime.js.map +0 -1
  273. package/dist/domain/queue/index.d.ts.map +0 -1
  274. package/dist/domain/queue/index.js.map +0 -1
  275. package/dist/domain/queue/queue.error.d.ts.map +0 -1
  276. package/dist/domain/queue/queue.error.js.map +0 -1
  277. package/dist/domain/queue/queueError.base.d.ts.map +0 -1
  278. package/dist/domain/queue/queueError.base.js.map +0 -1
  279. package/dist/domain/queue/queueError.job.d.ts.map +0 -1
  280. package/dist/domain/queue/queueError.job.js.map +0 -1
  281. package/dist/domain/queue/queueError.queue.d.ts.map +0 -1
  282. package/dist/domain/queue/queueError.queue.js.map +0 -1
  283. package/dist/domain/queue/queueError.worker.d.ts.map +0 -1
  284. package/dist/domain/queue/queueError.worker.js.map +0 -1
  285. package/dist/domain/rpc/index.d.ts.map +0 -1
  286. package/dist/domain/rpc/index.js.map +0 -1
  287. package/dist/domain/rpc/rpc.error.d.ts.map +0 -1
  288. package/dist/domain/rpc/rpc.error.js.map +0 -1
  289. package/dist/domain/rpc/rpcError.base.d.ts.map +0 -1
  290. package/dist/domain/rpc/rpcError.base.js.map +0 -1
  291. package/dist/domain/rpc/rpcError.protocol.d.ts.map +0 -1
  292. package/dist/domain/rpc/rpcError.protocol.js.map +0 -1
  293. package/dist/domain/rpc/rpcError.transport.d.ts.map +0 -1
  294. package/dist/domain/rpc/rpcError.transport.js.map +0 -1
  295. package/dist/domain/scheduler/index.d.ts.map +0 -1
  296. package/dist/domain/scheduler/index.js.map +0 -1
  297. package/dist/domain/scheduler/scheduler.error.d.ts.map +0 -1
  298. package/dist/domain/scheduler/scheduler.error.js.map +0 -1
  299. package/dist/domain/scheduler/schedulerError.base.d.ts.map +0 -1
  300. package/dist/domain/scheduler/schedulerError.base.js.map +0 -1
  301. package/dist/domain/scheduler/schedulerError.execution.d.ts.map +0 -1
  302. package/dist/domain/scheduler/schedulerError.execution.js.map +0 -1
  303. package/dist/domain/scheduler/schedulerError.schedule.d.ts.map +0 -1
  304. package/dist/domain/scheduler/schedulerError.schedule.js.map +0 -1
  305. package/dist/domain/schema/index.d.ts.map +0 -1
  306. package/dist/domain/schema/index.js.map +0 -1
  307. package/dist/domain/schema/schema.error.d.ts.map +0 -1
  308. package/dist/domain/schema/schema.error.js.map +0 -1
  309. package/dist/domain/schema/schemaError.base.d.ts.map +0 -1
  310. package/dist/domain/schema/schemaError.base.js.map +0 -1
  311. package/dist/domain/schema/schemaError.types.d.ts.map +0 -1
  312. package/dist/domain/schema/schemaError.types.js.map +0 -1
  313. package/dist/domain/serialization/index.d.ts.map +0 -1
  314. package/dist/domain/serialization/index.js.map +0 -1
  315. package/dist/domain/serialization/serialization.error.d.ts.map +0 -1
  316. package/dist/domain/serialization/serialization.error.js.map +0 -1
  317. package/dist/domain/serialization/serializationError.base.d.ts.map +0 -1
  318. package/dist/domain/serialization/serializationError.base.js.map +0 -1
  319. package/dist/domain/serialization/serializationError.types.d.ts.map +0 -1
  320. package/dist/domain/serialization/serializationError.types.js.map +0 -1
  321. package/dist/domain/state/conflict.error.d.ts.map +0 -1
  322. package/dist/domain/state/conflict.error.js.map +0 -1
  323. package/dist/domain/state/index.d.ts.map +0 -1
  324. package/dist/domain/state/index.js.map +0 -1
  325. package/dist/domain/state/notFound.error.d.ts.map +0 -1
  326. package/dist/domain/state/notFound.error.js.map +0 -1
  327. package/dist/domain/state/validation.error.d.ts.map +0 -1
  328. package/dist/domain/state/validation.error.js.map +0 -1
  329. package/dist/domain/state/validationError.base.d.ts.map +0 -1
  330. package/dist/domain/state/validationError.base.js.map +0 -1
  331. package/dist/domain/state/validationError.helpers.d.ts.map +0 -1
  332. package/dist/domain/state/validationError.helpers.js.map +0 -1
  333. package/dist/index.d.ts.map +0 -1
  334. package/dist/index.js.map +0 -1
  335. package/dist/infrastructure/adapter/adapter.error.d.ts.map +0 -1
  336. package/dist/infrastructure/adapter/adapter.error.js.map +0 -1
  337. package/dist/infrastructure/adapter/adapterError.base.d.ts.map +0 -1
  338. package/dist/infrastructure/adapter/adapterError.base.js.map +0 -1
  339. package/dist/infrastructure/adapter/adapterError.lifecycle.d.ts.map +0 -1
  340. package/dist/infrastructure/adapter/adapterError.lifecycle.js.map +0 -1
  341. package/dist/infrastructure/adapter/adapterError.operation.d.ts.map +0 -1
  342. package/dist/infrastructure/adapter/adapterError.operation.js.map +0 -1
  343. package/dist/infrastructure/adapter/index.d.ts.map +0 -1
  344. package/dist/infrastructure/adapter/index.js.map +0 -1
  345. package/dist/infrastructure/cache/cache.error.d.ts.map +0 -1
  346. package/dist/infrastructure/cache/cache.error.js.map +0 -1
  347. package/dist/infrastructure/cache/cacheError.base.d.ts.map +0 -1
  348. package/dist/infrastructure/cache/cacheError.base.js.map +0 -1
  349. package/dist/infrastructure/cache/cacheError.factory.d.ts.map +0 -1
  350. package/dist/infrastructure/cache/cacheError.factory.js.map +0 -1
  351. package/dist/infrastructure/cache/index.d.ts.map +0 -1
  352. package/dist/infrastructure/cache/index.js.map +0 -1
  353. package/dist/infrastructure/container/container.error.d.ts.map +0 -1
  354. package/dist/infrastructure/container/container.error.js.map +0 -1
  355. package/dist/infrastructure/container/containerError.base.d.ts.map +0 -1
  356. package/dist/infrastructure/container/containerError.base.js.map +0 -1
  357. package/dist/infrastructure/container/containerError.registration.d.ts.map +0 -1
  358. package/dist/infrastructure/container/containerError.registration.js.map +0 -1
  359. package/dist/infrastructure/container/index.d.ts.map +0 -1
  360. package/dist/infrastructure/container/index.js.map +0 -1
  361. package/dist/infrastructure/index.d.ts.map +0 -1
  362. package/dist/infrastructure/index.js.map +0 -1
  363. package/dist/infrastructure/middleware/index.d.ts.map +0 -1
  364. package/dist/infrastructure/middleware/index.js.map +0 -1
  365. package/dist/infrastructure/middleware/middleware.error.d.ts.map +0 -1
  366. package/dist/infrastructure/middleware/middleware.error.js.map +0 -1
  367. package/dist/infrastructure/network/http.error.d.ts.map +0 -1
  368. package/dist/infrastructure/network/http.error.js.map +0 -1
  369. package/dist/infrastructure/network/httpAdapter.error.d.ts.map +0 -1
  370. package/dist/infrastructure/network/httpAdapter.error.js.map +0 -1
  371. package/dist/infrastructure/network/httpClient.errors.d.ts.map +0 -1
  372. package/dist/infrastructure/network/httpClient.errors.js.map +0 -1
  373. package/dist/infrastructure/network/httpClientError.advanced.d.ts.map +0 -1
  374. package/dist/infrastructure/network/httpClientError.advanced.js.map +0 -1
  375. package/dist/infrastructure/network/httpClientError.base.d.ts.map +0 -1
  376. package/dist/infrastructure/network/httpClientError.base.js.map +0 -1
  377. package/dist/infrastructure/network/httpClientError.common.d.ts.map +0 -1
  378. package/dist/infrastructure/network/httpClientError.common.js.map +0 -1
  379. package/dist/infrastructure/network/httpClientError.error.d.ts.map +0 -1
  380. package/dist/infrastructure/network/httpClientError.error.js.map +0 -1
  381. package/dist/infrastructure/network/httpClientError.options.d.ts.map +0 -1
  382. package/dist/infrastructure/network/httpClientError.options.js.map +0 -1
  383. package/dist/infrastructure/network/httpClientError.specialized.d.ts.map +0 -1
  384. package/dist/infrastructure/network/httpClientError.specialized.js.map +0 -1
  385. package/dist/infrastructure/network/httpClientError.types.d.ts.map +0 -1
  386. package/dist/infrastructure/network/httpClientError.types.js.map +0 -1
  387. package/dist/infrastructure/network/httpError.base.d.ts.map +0 -1
  388. package/dist/infrastructure/network/httpError.base.js.map +0 -1
  389. package/dist/infrastructure/network/httpError.helpers.d.ts.map +0 -1
  390. package/dist/infrastructure/network/httpError.helpers.js.map +0 -1
  391. package/dist/infrastructure/network/httpResponse.error.d.ts.map +0 -1
  392. package/dist/infrastructure/network/httpResponse.error.js.map +0 -1
  393. package/dist/infrastructure/network/httpRouter.error.d.ts.map +0 -1
  394. package/dist/infrastructure/network/httpRouter.error.js.map +0 -1
  395. package/dist/infrastructure/network/httpRouterError.base.d.ts.map +0 -1
  396. package/dist/infrastructure/network/httpRouterError.base.js.map +0 -1
  397. package/dist/infrastructure/network/httpRouterError.types.d.ts.map +0 -1
  398. package/dist/infrastructure/network/httpRouterError.types.js.map +0 -1
  399. package/dist/infrastructure/network/httpServerError.error.d.ts.map +0 -1
  400. package/dist/infrastructure/network/httpServerError.error.js.map +0 -1
  401. package/dist/infrastructure/network/httpServerLifecycle.error.d.ts.map +0 -1
  402. package/dist/infrastructure/network/httpServerLifecycle.error.js.map +0 -1
  403. package/dist/infrastructure/network/httpServerLifecycleError.base.d.ts.map +0 -1
  404. package/dist/infrastructure/network/httpServerLifecycleError.base.js.map +0 -1
  405. package/dist/infrastructure/network/httpServerLifecycleError.types.d.ts.map +0 -1
  406. package/dist/infrastructure/network/httpServerLifecycleError.types.js.map +0 -1
  407. package/dist/infrastructure/network/httpStream.error.d.ts.map +0 -1
  408. package/dist/infrastructure/network/httpStream.error.js.map +0 -1
  409. package/dist/infrastructure/network/index.d.ts.map +0 -1
  410. package/dist/infrastructure/network/index.js.map +0 -1
  411. package/dist/infrastructure/network/network.error.d.ts.map +0 -1
  412. package/dist/infrastructure/network/network.error.js.map +0 -1
  413. package/dist/infrastructure/network/networkError.base.d.ts.map +0 -1
  414. package/dist/infrastructure/network/networkError.base.js.map +0 -1
  415. package/dist/infrastructure/network/networkError.factory.d.ts.map +0 -1
  416. package/dist/infrastructure/network/networkError.factory.js.map +0 -1
  417. package/dist/infrastructure/network/routePattern.error.d.ts.map +0 -1
  418. package/dist/infrastructure/network/routePattern.error.js.map +0 -1
  419. package/dist/infrastructure/network/timeout.error.d.ts.map +0 -1
  420. package/dist/infrastructure/network/timeout.error.js.map +0 -1
  421. package/dist/infrastructure/network/timeoutError.base.d.ts.map +0 -1
  422. package/dist/infrastructure/network/timeoutError.base.js.map +0 -1
  423. package/dist/infrastructure/network/timeoutError.factory.d.ts.map +0 -1
  424. package/dist/infrastructure/network/timeoutError.factory.js.map +0 -1
  425. package/dist/infrastructure/service/externalService.error.d.ts.map +0 -1
  426. package/dist/infrastructure/service/externalService.error.js.map +0 -1
  427. package/dist/infrastructure/service/externalServiceError.base.d.ts.map +0 -1
  428. package/dist/infrastructure/service/externalServiceError.base.js.map +0 -1
  429. package/dist/infrastructure/service/externalServiceError.factory.d.ts.map +0 -1
  430. package/dist/infrastructure/service/externalServiceError.factory.js.map +0 -1
  431. package/dist/infrastructure/service/index.d.ts.map +0 -1
  432. package/dist/infrastructure/service/index.js.map +0 -1
  433. package/dist/infrastructure/service/service.error.d.ts.map +0 -1
  434. package/dist/infrastructure/service/service.error.js.map +0 -1
  435. package/dist/infrastructure/service/serviceError.base.d.ts.map +0 -1
  436. package/dist/infrastructure/service/serviceError.base.js.map +0 -1
  437. package/dist/infrastructure/service/serviceError.factory.d.ts.map +0 -1
  438. package/dist/infrastructure/service/serviceError.factory.js.map +0 -1
  439. package/dist/infrastructure/storage/database.error.d.ts.map +0 -1
  440. package/dist/infrastructure/storage/database.error.js.map +0 -1
  441. package/dist/infrastructure/storage/databaseError.base.d.ts.map +0 -1
  442. package/dist/infrastructure/storage/databaseError.base.js.map +0 -1
  443. package/dist/infrastructure/storage/databaseError.factory.d.ts.map +0 -1
  444. package/dist/infrastructure/storage/databaseError.factory.js.map +0 -1
  445. package/dist/infrastructure/storage/index.d.ts.map +0 -1
  446. package/dist/infrastructure/storage/index.js.map +0 -1
  447. package/dist/infrastructure/storage/storage.error.d.ts.map +0 -1
  448. package/dist/infrastructure/storage/storage.error.js.map +0 -1
  449. package/dist/infrastructure/storage/storageError.base.d.ts.map +0 -1
  450. package/dist/infrastructure/storage/storageError.base.js.map +0 -1
  451. package/dist/infrastructure/storage/storageError.factory.d.ts.map +0 -1
  452. package/dist/infrastructure/storage/storageError.factory.js.map +0 -1
  453. package/dist/system/crypto.error.d.ts.map +0 -1
  454. package/dist/system/crypto.error.js.map +0 -1
  455. package/dist/system/cryptoError.base.d.ts.map +0 -1
  456. package/dist/system/cryptoError.base.js.map +0 -1
  457. package/dist/system/cryptoError.factory.d.ts.map +0 -1
  458. package/dist/system/cryptoError.factory.js.map +0 -1
  459. package/dist/system/index.d.ts.map +0 -1
  460. package/dist/system/index.js.map +0 -1
  461. package/dist/system/logging/index.d.ts.map +0 -1
  462. package/dist/system/logging/index.js.map +0 -1
  463. package/dist/system/logging/logging.error.d.ts.map +0 -1
  464. package/dist/system/logging/logging.error.js.map +0 -1
  465. package/dist/system/runtime.error.d.ts.map +0 -1
  466. package/dist/system/runtime.error.js.map +0 -1
  467. package/dist/system/runtimeError.base.d.ts.map +0 -1
  468. package/dist/system/runtimeError.base.js.map +0 -1
  469. package/dist/system/runtimeError.types.d.ts.map +0 -1
  470. package/dist/system/runtimeError.types.js.map +0 -1
  471. package/dist/system/system.error.d.ts.map +0 -1
  472. package/dist/system/system.error.js.map +0 -1
  473. package/dist/system/systemError.base.d.ts.map +0 -1
  474. package/dist/system/systemError.base.js.map +0 -1
  475. package/dist/system/systemError.factory.d.ts.map +0 -1
  476. package/dist/system/systemError.factory.js.map +0 -1
  477. package/dist/utils/errorHandler.core.d.ts.map +0 -1
  478. package/dist/utils/errorHandler.core.js.map +0 -1
  479. package/dist/utils/errorHandler.factory.d.ts.map +0 -1
  480. package/dist/utils/errorHandler.factory.js.map +0 -1
  481. package/dist/utils/errorHandler.types.d.ts.map +0 -1
  482. package/dist/utils/errorHandler.types.js.map +0 -1
  483. package/dist/utils/errorMapper.core.d.ts.map +0 -1
  484. package/dist/utils/errorMapper.core.js.map +0 -1
  485. package/dist/utils/errorMapper.mappers.d.ts.map +0 -1
  486. package/dist/utils/errorMapper.mappers.js.map +0 -1
  487. package/dist/utils/errorMapper.registry.d.ts.map +0 -1
  488. package/dist/utils/errorMapper.registry.js.map +0 -1
  489. package/dist/utils/errorMapper.types.d.ts.map +0 -1
  490. package/dist/utils/errorMapper.types.js.map +0 -1
  491. package/dist/utils/errorSerializer.core.d.ts.map +0 -1
  492. package/dist/utils/errorSerializer.core.js.map +0 -1
  493. package/dist/utils/errorSerializer.factory.d.ts.map +0 -1
  494. package/dist/utils/errorSerializer.factory.js.map +0 -1
  495. package/dist/utils/errorSerializer.types.d.ts.map +0 -1
  496. package/dist/utils/errorSerializer.types.js.map +0 -1
  497. package/dist/utils/errorUtils.extraction.d.ts.map +0 -1
  498. package/dist/utils/errorUtils.extraction.js.map +0 -1
  499. package/dist/utils/errorUtils.helper.d.ts.map +0 -1
  500. package/dist/utils/errorUtils.helper.js.map +0 -1
  501. package/dist/utils/errorUtils.transform.d.ts.map +0 -1
  502. package/dist/utils/errorUtils.transform.js.map +0 -1
  503. package/dist/utils/errorUtils.typeCheck.d.ts.map +0 -1
  504. package/dist/utils/errorUtils.typeCheck.js.map +0 -1
  505. package/dist/utils/index.d.ts.map +0 -1
  506. package/dist/utils/index.js.map +0 -1
@@ -2,13 +2,19 @@
2
2
  * Specific schema error classes.
3
3
  */
4
4
  import { ErrorCode } from "../../base/types/errorCode.type.js";
5
+ import { describeValue, safeStringify, sanitizeFragment, } from "../shared/domainError.helpers.js";
5
6
  import { SchemaError } from "./schemaError.base.js";
7
+ /*
8
+ * Messages built here never embed the received (submitted) value; they use a
9
+ * type/size description instead. Expected values come from the schema
10
+ * definition and are serialized with a non-throwing stringifier.
11
+ */
6
12
  /**
7
13
  * Error thrown when a value does not match the expected type.
8
14
  */
9
15
  export class SchemaTypeError extends SchemaError {
10
16
  constructor(expected, received, path = []) {
11
- super(`Expected ${expected}, received ${received}`, {
17
+ super(`Expected ${sanitizeFragment(expected)}, received ${sanitizeFragment(received)}`, {
12
18
  code: ErrorCode.SCHEMA_INVALID_TYPE,
13
19
  issues: [{ code: "invalid_type", path, expected, received }],
14
20
  });
@@ -19,7 +25,7 @@ export class SchemaTypeError extends SchemaError {
19
25
  */
20
26
  export class SchemaLiteralError extends SchemaError {
21
27
  constructor(expected, received, path = []) {
22
- super(`Expected literal ${JSON.stringify(expected)}, received ${JSON.stringify(received)}`, {
28
+ super(`Expected literal ${sanitizeFragment(safeStringify(expected))}, received ${describeValue(received)}`, {
23
29
  code: ErrorCode.SCHEMA_INVALID_LITERAL,
24
30
  issues: [{ code: "invalid_literal", path, expected, received }],
25
31
  });
@@ -30,7 +36,7 @@ export class SchemaLiteralError extends SchemaError {
30
36
  */
31
37
  export class SchemaEnumError extends SchemaError {
32
38
  constructor(expected, received, path = []) {
33
- super(`Expected one of ${expected.map((v) => JSON.stringify(v)).join(", ")}`, {
39
+ super(`Expected one of ${sanitizeFragment(expected.map((v) => safeStringify(v)).join(", "))}, received ${describeValue(received)}`, {
34
40
  code: ErrorCode.SCHEMA_INVALID_ENUM,
35
41
  issues: [{ code: "invalid_enum", path, expected, received }],
36
42
  });
@@ -85,9 +91,10 @@ export class SchemaUnionError extends SchemaError {
85
91
  */
86
92
  export class SchemaUnknownKeyError extends SchemaError {
87
93
  constructor(key, path = []) {
88
- super(`Unknown key: ${key}`, {
94
+ const safeKey = sanitizeFragment(key);
95
+ super(`Unknown key: ${safeKey}`, {
89
96
  code: ErrorCode.SCHEMA_UNKNOWN_KEY,
90
- issues: [{ code: "unknown_keys", path, key }],
97
+ issues: [{ code: "unknown_keys", path, key: safeKey }],
91
98
  });
92
99
  }
93
100
  }
@@ -4,6 +4,7 @@
4
4
  import { BaseError } from "../../base/core/baseError.core.js";
5
5
  import type { BaseErrorOptions } from "../../base/types/baseError.type.js";
6
6
  import { ErrorCategory } from "../../base/types/errorCategory.type.js";
7
+ import { ErrorCode } from "../../base/types/errorCode.type.js";
7
8
  import { ErrorSeverity } from "../../base/types/errorSeverity.type.js";
8
9
  /** Options for creating a serialization error. */
9
10
  export interface SerializationErrorOptions extends Omit<BaseErrorOptions, "category"> {
@@ -19,6 +20,12 @@ export interface SerializationErrorOptions extends Omit<BaseErrorOptions, "categ
19
20
  /** Base error for all serialization subsystem failures. */
20
21
  export declare class SerializationError extends BaseError {
21
22
  readonly format?: string;
23
+ readonly depth?: number;
24
+ readonly maxDepth?: number;
25
+ readonly size?: number;
26
+ readonly maxSize?: number;
27
+ readonly transformerType?: string;
28
+ readonly serializerName?: string;
22
29
  constructor(message: string, options?: SerializationErrorOptions);
23
30
  toJSON(): {
24
31
  name: string;
@@ -32,7 +39,6 @@ export declare class SerializationError extends BaseError {
32
39
  metadata: Readonly<import("../../index.js").ErrorMetadata>;
33
40
  stack?: string;
34
41
  cause?: import("../../base/types/baseError.type.js").SerializedBaseError | unknown;
35
- format?: string | undefined;
36
42
  };
37
43
  }
38
44
  /** Creates a serialization error. */
@@ -42,6 +48,6 @@ export declare function isSerializationError(value: unknown): value is Serializa
42
48
  /** Converts an unknown thrown value into a SerializationError. */
43
49
  export declare function toSerializationError(error: unknown, options?: {
44
50
  message?: string;
45
- code?: string;
51
+ code?: ErrorCode | string;
46
52
  }): SerializationError;
47
53
  //# sourceMappingURL=serializationError.base.d.ts.map
@@ -5,10 +5,33 @@ import { BaseError } from "../../base/core/baseError.core.js";
5
5
  import { ErrorCategory } from "../../base/types/errorCategory.type.js";
6
6
  import { ErrorCode } from "../../base/types/errorCode.type.js";
7
7
  import { ErrorSeverity } from "../../base/types/errorSeverity.type.js";
8
+ import { safeErrorMessage } from "../shared/domainError.helpers.js";
9
+ /** Diagnostic fields carried by serialization errors. */
10
+ const DIAGNOSTIC_KEYS = [
11
+ "format",
12
+ "depth",
13
+ "maxDepth",
14
+ "size",
15
+ "maxSize",
16
+ "transformerType",
17
+ "serializerName",
18
+ ];
8
19
  /** Base error for all serialization subsystem failures. */
9
20
  export class SerializationError extends BaseError {
10
21
  format;
22
+ depth;
23
+ maxDepth;
24
+ size;
25
+ maxSize;
26
+ transformerType;
27
+ serializerName;
11
28
  constructor(message, options = {}) {
29
+ const diagnostics = {};
30
+ for (const key of DIAGNOSTIC_KEYS) {
31
+ const value = options[key];
32
+ if (value !== undefined)
33
+ diagnostics[key] = value;
34
+ }
12
35
  super(message, {
13
36
  ...options,
14
37
  code: options.code ?? ErrorCode.SERIALIZATION,
@@ -17,13 +40,26 @@ export class SerializationError extends BaseError {
17
40
  statusCode: options.statusCode ?? 500,
18
41
  expose: options.expose ?? false,
19
42
  isOperational: options.isOperational ?? true,
43
+ metadata: { ...options.metadata, ...diagnostics },
20
44
  });
21
45
  this.format = options.format;
46
+ this.depth = options.depth;
47
+ this.maxDepth = options.maxDepth;
48
+ this.size = options.size;
49
+ this.maxSize = options.maxSize;
50
+ this.transformerType = options.transformerType;
51
+ this.serializerName = options.serializerName;
22
52
  }
23
53
  toJSON() {
54
+ const diagnostics = {};
55
+ for (const key of DIAGNOSTIC_KEYS) {
56
+ const value = this[key];
57
+ if (value !== undefined)
58
+ diagnostics[key] = value;
59
+ }
24
60
  return {
25
61
  ...super.toJSON(),
26
- ...(this.format !== undefined ? { format: this.format } : {}),
62
+ ...diagnostics,
27
63
  };
28
64
  }
29
65
  }
@@ -40,13 +76,7 @@ export function toSerializationError(error, options = {}) {
40
76
  if (error instanceof SerializationError) {
41
77
  return error;
42
78
  }
43
- if (error instanceof Error) {
44
- return new SerializationError(options.message ?? error.message, {
45
- code: options.code,
46
- cause: error,
47
- });
48
- }
49
- return new SerializationError(options.message ?? String(error), {
79
+ return new SerializationError(options.message ?? safeErrorMessage(error), {
50
80
  code: options.code,
51
81
  cause: error,
52
82
  });
@@ -9,7 +9,12 @@ export declare class SerializeError extends SerializationError {
9
9
  cause?: unknown;
10
10
  });
11
11
  }
12
- /** Error thrown when deserialization fails. */
12
+ /**
13
+ * Error thrown when deserialization fails.
14
+ *
15
+ * Malformed serialized input is a client/input problem, so this is a 400
16
+ * that may be exposed.
17
+ */
13
18
  export declare class DeserializeError extends SerializationError {
14
19
  constructor(message: string, options?: {
15
20
  format?: string;
@@ -25,20 +30,34 @@ export declare class SerializerNotFoundError extends SerializationError {
25
30
  readonly serializerName: string;
26
31
  constructor(name: string);
27
32
  }
28
- /** Error thrown when a circular reference is detected during serialization. */
33
+ /**
34
+ * Error thrown when a circular reference is detected during serialization.
35
+ *
36
+ * Circular data is a server-side data bug, so this is an internal (500) error.
37
+ */
29
38
  export declare class CircularReferenceError extends SerializationError {
30
39
  readonly circularPath: string;
31
40
  constructor(path?: string);
32
41
  }
33
- /** Error thrown when maximum serialization depth is exceeded. */
42
+ /**
43
+ * Error thrown when maximum serialization depth is exceeded.
44
+ *
45
+ * Over-deep data is a server-side data bug, so this is an internal (500) error.
46
+ */
34
47
  export declare class SerializationDepthError extends SerializationError {
35
48
  readonly depth: number;
49
+ readonly maxDepth: number;
50
+ /** @deprecated Use `maxDepth`. */
36
51
  readonly maxDepthValue: number;
37
52
  constructor(depth: number, maxDepth: number);
38
53
  }
39
54
  /** Error thrown when a serialized payload exceeds the size limit. */
40
55
  export declare class SerializationPayloadTooLargeError extends SerializationError {
56
+ readonly size: number;
57
+ readonly maxSize: number;
58
+ /** @deprecated Use `size`. */
41
59
  readonly payloadSize: number;
60
+ /** @deprecated Use `maxSize`. */
42
61
  readonly maxSizeValue: number;
43
62
  constructor(size: number, maxSize: number);
44
63
  }
@@ -13,13 +13,20 @@ export class SerializeError extends SerializationError {
13
13
  });
14
14
  }
15
15
  }
16
- /** Error thrown when deserialization fails. */
16
+ /**
17
+ * Error thrown when deserialization fails.
18
+ *
19
+ * Malformed serialized input is a client/input problem, so this is a 400
20
+ * that may be exposed.
21
+ */
17
22
  export class DeserializeError extends SerializationError {
18
23
  constructor(message, options = {}) {
19
24
  super(message, {
20
25
  code: ErrorCode.DESERIALIZATION_FAILED,
21
26
  format: options.format,
22
27
  cause: options.cause,
28
+ statusCode: 400,
29
+ expose: true,
23
30
  });
24
31
  }
25
32
  }
@@ -47,37 +54,53 @@ export class SerializerNotFoundError extends SerializationError {
47
54
  this.serializerName = name;
48
55
  }
49
56
  }
50
- /** Error thrown when a circular reference is detected during serialization. */
57
+ /**
58
+ * Error thrown when a circular reference is detected during serialization.
59
+ *
60
+ * Circular data is a server-side data bug, so this is an internal (500) error.
61
+ */
51
62
  export class CircularReferenceError extends SerializationError {
52
63
  circularPath;
53
64
  constructor(path = "root") {
54
65
  super(`Circular reference detected at "${path}"`, {
55
66
  code: ErrorCode.CIRCULAR_REFERENCE,
56
- statusCode: 400,
67
+ statusCode: 500,
57
68
  expose: false,
69
+ metadata: { circularPath: path },
58
70
  });
59
71
  this.circularPath = path;
60
72
  }
61
73
  }
62
- /** Error thrown when maximum serialization depth is exceeded. */
74
+ /**
75
+ * Error thrown when maximum serialization depth is exceeded.
76
+ *
77
+ * Over-deep data is a server-side data bug, so this is an internal (500) error.
78
+ */
63
79
  export class SerializationDepthError extends SerializationError {
64
80
  depth;
81
+ maxDepth;
82
+ /** @deprecated Use `maxDepth`. */
65
83
  maxDepthValue;
66
84
  constructor(depth, maxDepth) {
67
85
  super(`Maximum serialization depth exceeded: ${depth} > ${maxDepth}`, {
68
86
  code: ErrorCode.MAX_DEPTH_EXCEEDED,
69
87
  depth,
70
88
  maxDepth,
71
- statusCode: 400,
89
+ statusCode: 500,
72
90
  expose: false,
73
91
  });
74
92
  this.depth = depth;
93
+ this.maxDepth = maxDepth;
75
94
  this.maxDepthValue = maxDepth;
76
95
  }
77
96
  }
78
97
  /** Error thrown when a serialized payload exceeds the size limit. */
79
98
  export class SerializationPayloadTooLargeError extends SerializationError {
99
+ size;
100
+ maxSize;
101
+ /** @deprecated Use `size`. */
80
102
  payloadSize;
103
+ /** @deprecated Use `maxSize`. */
81
104
  maxSizeValue;
82
105
  constructor(size, maxSize) {
83
106
  super(`Serialized payload too large: ${size} bytes (max: ${maxSize})`, {
@@ -87,6 +110,8 @@ export class SerializationPayloadTooLargeError extends SerializationError {
87
110
  statusCode: 413,
88
111
  expose: false,
89
112
  });
113
+ this.size = size;
114
+ this.maxSize = maxSize;
90
115
  this.payloadSize = size;
91
116
  this.maxSizeValue = maxSize;
92
117
  }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Shared helpers for domain error classes.
3
+ *
4
+ * These utilities keep untrusted input out of error messages, make
5
+ * normalizers robust against exotic thrown values, and validate the
6
+ * numeric arguments that domain errors record.
7
+ */
8
+ import type { ErrorMetadata } from "../../base/core/errorMetadata.type.js";
9
+ /** Default maximum length for untrusted strings embedded in messages. */
10
+ export declare const MAX_MESSAGE_FRAGMENT_LENGTH = 200;
11
+ /** Default maximum length for untrusted strings stored in metadata. */
12
+ export declare const MAX_METADATA_FRAGMENT_LENGTH = 1024;
13
+ /**
14
+ * Removes control characters (including newlines and ANSI escapes) and
15
+ * truncates the string so it can be safely embedded in a message or log line.
16
+ */
17
+ export declare function sanitizeFragment(value: unknown, maxLength?: number): string;
18
+ /**
19
+ * Serializes any value to a string without throwing.
20
+ *
21
+ * Handles BigInt, circular structures, symbols, and objects whose
22
+ * `toString` throws. Never returns more than `maxLength` characters.
23
+ */
24
+ export declare function safeStringify(value: unknown, maxLength?: number): string;
25
+ /**
26
+ * Describes a value by type and size without revealing its contents.
27
+ *
28
+ * Use this instead of embedding submitted values into exposed messages.
29
+ */
30
+ export declare function describeValue(value: unknown): string;
31
+ /**
32
+ * Produces a message for an unknown thrown value without throwing.
33
+ */
34
+ export declare function safeErrorMessage(error: unknown): string;
35
+ /**
36
+ * Asserts that a numeric argument is finite and non-negative.
37
+ */
38
+ export declare function assertFiniteNonNegative(name: string, value: number): number;
39
+ /**
40
+ * Normalizes a retry-after value in seconds to a finite, non-negative integer
41
+ * (rounded up), as required by the HTTP `Retry-After` header.
42
+ */
43
+ export declare function normalizeRetryAfterSeconds(value: number, name?: string): number;
44
+ /**
45
+ * Merges caller-provided metadata with class-specific fields, letting the
46
+ * class-specific fields win.
47
+ */
48
+ export declare function mergeMetadata(callerMetadata: ErrorMetadata | undefined, own: ErrorMetadata): ErrorMetadata;
49
+ /**
50
+ * Removes submitted values from a list of issue objects so they can be
51
+ * exposed to clients. Values are replaced by a type/size description under
52
+ * `<key>Type`.
53
+ */
54
+ export declare function redactIssueValues<T>(issues: readonly T[]): readonly T[];
55
+ /**
56
+ * Converts issue objects into JSON-safe structures (no BigInt, no cycles)
57
+ * so that `JSON.stringify` on the error never throws.
58
+ */
59
+ export declare function toJsonSafeIssues<T>(issues: readonly T[]): readonly T[];
60
+ //# sourceMappingURL=domainError.helpers.d.ts.map
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Shared helpers for domain error classes.
3
+ *
4
+ * These utilities keep untrusted input out of error messages, make
5
+ * normalizers robust against exotic thrown values, and validate the
6
+ * numeric arguments that domain errors record.
7
+ */
8
+ /** Default maximum length for untrusted strings embedded in messages. */
9
+ export const MAX_MESSAGE_FRAGMENT_LENGTH = 200;
10
+ /** Control characters (C0 range, DEL, and C1 range) that must not reach logs. */
11
+ // eslint-disable-next-line no-control-regex
12
+ const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f]/g;
13
+ /** Default maximum length for untrusted strings stored in metadata. */
14
+ export const MAX_METADATA_FRAGMENT_LENGTH = 1024;
15
+ /**
16
+ * Removes control characters (including newlines and ANSI escapes) and
17
+ * truncates the string so it can be safely embedded in a message or log line.
18
+ */
19
+ export function sanitizeFragment(value, maxLength = MAX_MESSAGE_FRAGMENT_LENGTH) {
20
+ const text = typeof value === "string" ? value : safeStringify(value);
21
+ const cleaned = text.replace(CONTROL_CHARS, " ");
22
+ if (cleaned.length <= maxLength)
23
+ return cleaned;
24
+ return `${cleaned.slice(0, maxLength)}… [truncated ${cleaned.length - maxLength} chars]`;
25
+ }
26
+ /**
27
+ * Serializes any value to a string without throwing.
28
+ *
29
+ * Handles BigInt, circular structures, symbols, and objects whose
30
+ * `toString` throws. Never returns more than `maxLength` characters.
31
+ */
32
+ export function safeStringify(value, maxLength = MAX_METADATA_FRAGMENT_LENGTH) {
33
+ let text;
34
+ try {
35
+ if (typeof value === "string") {
36
+ text = value;
37
+ }
38
+ else if (typeof value === "bigint") {
39
+ text = `${value.toString()}n`;
40
+ }
41
+ else if (typeof value === "symbol") {
42
+ text = value.toString();
43
+ }
44
+ else if (typeof value === "function") {
45
+ text = `[function ${value.name || "anonymous"}]`;
46
+ }
47
+ else if (value === undefined) {
48
+ text = "undefined";
49
+ }
50
+ else {
51
+ const seen = new WeakSet();
52
+ const json = JSON.stringify(value, (_key, item) => {
53
+ if (typeof item === "bigint")
54
+ return `${item.toString()}n`;
55
+ if (typeof item === "symbol")
56
+ return item.toString();
57
+ if (typeof item === "object" && item !== null) {
58
+ if (seen.has(item))
59
+ return "[Circular]";
60
+ seen.add(item);
61
+ }
62
+ return item;
63
+ });
64
+ text = json === undefined ? String(value) : json;
65
+ }
66
+ }
67
+ catch {
68
+ try {
69
+ text = Object.prototype.toString.call(value);
70
+ }
71
+ catch {
72
+ text = "[unserializable]";
73
+ }
74
+ }
75
+ if (text.length <= maxLength)
76
+ return text;
77
+ return `${text.slice(0, maxLength)}…`;
78
+ }
79
+ /**
80
+ * Describes a value by type and size without revealing its contents.
81
+ *
82
+ * Use this instead of embedding submitted values into exposed messages.
83
+ */
84
+ export function describeValue(value) {
85
+ if (value === null)
86
+ return "null";
87
+ if (value === undefined)
88
+ return "undefined";
89
+ if (Array.isArray(value))
90
+ return `array(${value.length})`;
91
+ switch (typeof value) {
92
+ case "string":
93
+ return `string(${value.length})`;
94
+ case "number":
95
+ return Number.isFinite(value) ? "number" : `number(${String(value)})`;
96
+ case "bigint":
97
+ return "bigint";
98
+ case "boolean":
99
+ return `boolean(${String(value)})`;
100
+ case "symbol":
101
+ return "symbol";
102
+ case "function":
103
+ return "function";
104
+ default: {
105
+ if (value instanceof Date)
106
+ return "date";
107
+ const proto = Object.getPrototypeOf(value);
108
+ if (proto === null || proto === Object.prototype)
109
+ return "object";
110
+ const name = value.constructor
111
+ ?.name;
112
+ return name ? `object(${name})` : "object";
113
+ }
114
+ }
115
+ }
116
+ /**
117
+ * Produces a message for an unknown thrown value without throwing.
118
+ */
119
+ export function safeErrorMessage(error) {
120
+ if (error instanceof Error) {
121
+ return typeof error.message === "string" ? error.message : "Unknown error";
122
+ }
123
+ if (typeof error === "string")
124
+ return error;
125
+ if (error === null || error === undefined)
126
+ return "Unknown error";
127
+ const text = safeStringify(error, MAX_MESSAGE_FRAGMENT_LENGTH);
128
+ return text.length > 0 ? text : "Unknown error";
129
+ }
130
+ /**
131
+ * Asserts that a numeric argument is finite and non-negative.
132
+ */
133
+ export function assertFiniteNonNegative(name, value) {
134
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
135
+ throw new RangeError(`${name} must be a finite non-negative number.`);
136
+ }
137
+ return value;
138
+ }
139
+ /**
140
+ * Normalizes a retry-after value in seconds to a finite, non-negative integer
141
+ * (rounded up), as required by the HTTP `Retry-After` header.
142
+ */
143
+ export function normalizeRetryAfterSeconds(value, name = "retryAfterSeconds") {
144
+ return Math.ceil(assertFiniteNonNegative(name, value));
145
+ }
146
+ /**
147
+ * Merges caller-provided metadata with class-specific fields, letting the
148
+ * class-specific fields win.
149
+ */
150
+ export function mergeMetadata(callerMetadata, own) {
151
+ return { ...(callerMetadata ?? {}), ...own };
152
+ }
153
+ /** Keys that hold submitted values inside validation/schema issues. */
154
+ const VALUE_KEYS = new Set(["value", "received", "input", "actual"]);
155
+ /**
156
+ * Removes submitted values from a list of issue objects so they can be
157
+ * exposed to clients. Values are replaced by a type/size description under
158
+ * `<key>Type`.
159
+ */
160
+ export function redactIssueValues(issues) {
161
+ return issues.map((issue) => {
162
+ if (typeof issue !== "object" || issue === null || Array.isArray(issue)) {
163
+ return issue;
164
+ }
165
+ const out = {};
166
+ for (const [key, val] of Object.entries(issue)) {
167
+ if (VALUE_KEYS.has(key)) {
168
+ out[`${key}Type`] = describeValue(val);
169
+ }
170
+ else {
171
+ out[key] = val;
172
+ }
173
+ }
174
+ return out;
175
+ });
176
+ }
177
+ /**
178
+ * Converts issue objects into JSON-safe structures (no BigInt, no cycles)
179
+ * so that `JSON.stringify` on the error never throws.
180
+ */
181
+ export function toJsonSafeIssues(issues) {
182
+ return issues.map((issue) => {
183
+ try {
184
+ return JSON.parse(safeStringify(issue, Number.POSITIVE_INFINITY));
185
+ }
186
+ catch {
187
+ return issue;
188
+ }
189
+ });
190
+ }
191
+ //# sourceMappingURL=domainError.helpers.js.map
@@ -21,6 +21,6 @@ export declare function isConflictError(value: unknown): value is ConflictError;
21
21
  export declare function alreadyExistsError(resource: string, identifier?: string | number): ConflictError;
22
22
  /** Creates an error indicating that a duplicate value was submitted. */
23
23
  export declare function duplicateError(field: string, value?: string | number): ConflictError;
24
- /** Creates an error indicating that a resource is currently locked. */
24
+ /** Creates an error indicating that a resource is currently locked (HTTP 423). */
25
25
  export declare function resourceLockedError(resource: string, identifier?: string | number): ConflictError;
26
26
  //# sourceMappingURL=conflict.error.d.ts.map
@@ -58,7 +58,7 @@ export function duplicateError(field, value) {
58
58
  },
59
59
  });
60
60
  }
61
- /** Creates an error indicating that a resource is currently locked. */
61
+ /** Creates an error indicating that a resource is currently locked (HTTP 423). */
62
62
  export function resourceLockedError(resource, identifier) {
63
63
  const message = identifier !== undefined
64
64
  ? `${resource} with identifier "${String(identifier)}" is currently locked.`
@@ -66,7 +66,7 @@ export function resourceLockedError(resource, identifier) {
66
66
  return new ConflictError(message, {
67
67
  code: ErrorCode.RESOURCE_LOCKED,
68
68
  category: ErrorCategory.CONFLICT,
69
- statusCode: 409,
69
+ statusCode: 423,
70
70
  expose: true,
71
71
  metadata: {
72
72
  resource,
@@ -31,7 +31,14 @@ export declare class ValidationError extends BaseError {
31
31
  get issueCount(): number;
32
32
  /** Returns issues associated with a specific field. */
33
33
  issuesForField(field: string): readonly ValidationIssue[];
34
- /** Returns a serialized representation including validation issues. */
34
+ /**
35
+ * Returns a serialized representation including validation issues.
36
+ *
37
+ * When the error is exposable (the default), submitted values inside
38
+ * issues (`value`) are replaced by a type/size description so that secrets
39
+ * such as passwords are never echoed to clients or written to logs. The
40
+ * output is always JSON-safe (BigInt and cyclic values are stringified).
41
+ */
35
42
  toJSON(): {
36
43
  name: string;
37
44
  message: string;
@@ -2,6 +2,7 @@ import { BaseError } from "../../base/core/baseError.core.js";
2
2
  import { ErrorCategory } from "../../base/types/errorCategory.type.js";
3
3
  import { ErrorCode } from "../../base/types/errorCode.type.js";
4
4
  import { ErrorSeverity } from "../../base/types/errorSeverity.type.js";
5
+ import { redactIssueValues, toJsonSafeIssues, } from "../shared/domainError.helpers.js";
5
6
  /**
6
7
  * Error raised when input fails validation.
7
8
  */
@@ -31,11 +32,19 @@ export class ValidationError extends BaseError {
31
32
  issuesForField(field) {
32
33
  return this.issues.filter((issue) => issue.field === field || issue.path?.[0] === field);
33
34
  }
34
- /** Returns a serialized representation including validation issues. */
35
+ /**
36
+ * Returns a serialized representation including validation issues.
37
+ *
38
+ * When the error is exposable (the default), submitted values inside
39
+ * issues (`value`) are replaced by a type/size description so that secrets
40
+ * such as passwords are never echoed to clients or written to logs. The
41
+ * output is always JSON-safe (BigInt and cyclic values are stringified).
42
+ */
35
43
  toJSON() {
44
+ const safeIssues = toJsonSafeIssues(this.issues);
36
45
  return {
37
46
  ...super.toJSON(),
38
- issues: this.issues,
47
+ issues: this.expose ? redactIssueValues(safeIssues) : safeIssues,
39
48
  };
40
49
  }
41
50
  }
@@ -41,10 +41,10 @@ export class AdapterNotFoundError extends AdapterError {
41
41
  super(`Adapter "${adapterName}" is not registered.`, {
42
42
  code: ErrorCode.ADAPTER_NOT_FOUND,
43
43
  adapter: adapterName,
44
- statusCode: 404,
45
- expose: true,
44
+ statusCode: 500,
45
+ expose: false,
46
+ isOperational: false,
46
47
  });
47
- this.name = "AdapterNotFoundError";
48
48
  }
49
49
  }
50
50
  /** Error thrown when an adapter is already registered. */
@@ -53,10 +53,10 @@ export class AdapterAlreadyRegisteredError extends AdapterError {
53
53
  super(`Adapter "${adapterName}" is already registered.`, {
54
54
  code: ErrorCode.ADAPTER_ALREADY_REGISTERED,
55
55
  adapter: adapterName,
56
- statusCode: 409,
57
- expose: true,
56
+ statusCode: 500,
57
+ expose: false,
58
+ isOperational: false,
58
59
  });
59
- this.name = "AdapterAlreadyRegisteredError";
60
60
  }
61
61
  }
62
62
  //# sourceMappingURL=adapterError.base.js.map