@devp0nt/error0 1.0.0-next.2 → 1.0.0-next.21

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/src/index.ts CHANGED
@@ -1,81 +1,71 @@
1
1
  import { Meta0 } from '@devp0nt/meta0'
2
+ import { meta0PluginTag } from '@devp0nt/meta0/plugins/meta0-plugin-tag'
2
3
  import { type AxiosError, HttpStatusCode, isAxiosError } from 'axios'
3
4
  import get from 'lodash/get.js'
4
5
  import { ZodError } from 'zod'
5
6
 
7
+ // TODO: Эррор 0 можно передать и вторым аргументом в логгер, тогда её месадж попадёт в мету, а первый месадж в сам месадж логера
8
+ // TODO: Зод, аксиос, это всё плагины
9
+ // TODO: В эррор0 добавить ориджинал
6
10
  // TODO: store tags as array from all causes
7
11
  // TODO: not use self stack if toError0
8
12
  // TODO: fix default message in extended error0, should be used in constuctor of Error0
9
13
  // TODO: remove defaults prop from getPropsFromUnknown
10
14
  // TODO: code has enum type, fn to check if code exists
11
15
 
12
- export interface Error0Input {
13
- message?: string
14
- tag?: string
15
- code?: string
16
- httpStatus?: HttpStatusCode | HttpStatusCodeString
17
- expected?: boolean | ExpectedFn
18
- clientMessage?: string
19
- cause?: Error0Cause
20
- stack?: string
21
- meta?: Meta0.Meta0OrValueTypeNullish
22
- zodError?: ZodError
23
- axiosError?: AxiosError
16
+ const isFilled = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined && value !== ''
17
+ const toStringOrUndefined = (value: unknown): string | undefined => {
18
+ return typeof value === 'string' ? value : undefined
24
19
  }
25
-
26
- interface Error0GeneralProps {
27
- message: Error0Input['message']
28
- tag: Error0Input['tag']
29
- code: Error0Input['code']
30
- httpStatus: number | undefined
31
- expected: boolean | undefined
32
- clientMessage: Error0Input['clientMessage']
33
- anyMessage: string | undefined
34
- cause: Error0Input['cause']
35
- stack: Error['stack']
36
- meta: Meta0.ValueType
37
- zodError?: ZodError
38
- axiosError?: AxiosError
20
+ const toNumberOrUndefined = (value: unknown): number | undefined => {
21
+ if (typeof value === 'number') {
22
+ return value
23
+ }
24
+ const number = Number(value)
25
+ if (typeof value === 'string' && !Number.isNaN(number)) {
26
+ return number
27
+ }
28
+ return undefined
29
+ }
30
+ const toBooleanOrUndefined = (value: unknown): boolean | undefined => {
31
+ if (typeof value === 'boolean') {
32
+ return value
33
+ }
34
+ return undefined
39
35
  }
40
-
41
- type HttpStatusCodeString = keyof typeof HttpStatusCode
42
- type Error0Cause = Error | Error0 | unknown
43
- type ExpectedFn = (error: Error0GeneralProps) => boolean | undefined
44
-
45
- const isFilled = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined && value !== ''
46
36
 
47
37
  export class Error0 extends Error {
48
- public readonly __I_AM_ERROR_0: true = true
49
-
50
- public readonly tag?: Error0GeneralProps['tag']
51
- public readonly code?: Error0GeneralProps['code']
52
- public readonly httpStatus?: Error0GeneralProps['httpStatus']
53
- public readonly expected?: Error0GeneralProps['expected']
54
- public readonly clientMessage?: Error0GeneralProps['clientMessage']
55
- public readonly anyMessage?: Error0GeneralProps['anyMessage']
56
- public override readonly cause?: Error0GeneralProps['cause']
57
- public readonly meta?: Meta0.Meta0OrValueTypeNullish
58
- public readonly zodError?: Error0GeneralProps['zodError']
59
- public readonly axiosError?: Error0GeneralProps['axiosError']
38
+ public readonly __I_AM_ERROR_0 = true as const
39
+
40
+ public readonly tag?: Error0.GeneralProps['tag']
41
+ public readonly code?: Error0.GeneralProps['code']
42
+ public readonly httpStatus?: Error0.GeneralProps['httpStatus']
43
+ public readonly expected?: Error0.GeneralProps['expected']
44
+ public readonly clientMessage?: Error0.GeneralProps['clientMessage']
45
+ public readonly anyMessage?: Error0.GeneralProps['anyMessage']
46
+ public override readonly cause?: Error0.GeneralProps['cause']
47
+ public readonly meta?: Meta0.ValueTypeNullish
48
+ public readonly zodError?: Error0.GeneralProps['zodError']
49
+ public readonly axiosError?: Error0.GeneralProps['axiosError']
60
50
 
61
51
  static defaultMessage = 'Unknown error'
62
- static defaultCode?: Error0GeneralProps['code']
63
- static defaultHttpStatus?: Error0GeneralProps['httpStatus']
64
- static defaultExpected?: Error0GeneralProps['expected']
65
- static defaultClientMessage?: Error0GeneralProps['clientMessage']
52
+ static defaultCode?: Error0.GeneralProps['code']
53
+ static defaultHttpStatus?: Error0.GeneralProps['httpStatus']
54
+ static defaultExpected?: Error0.GeneralProps['expected']
55
+ static defaultClientMessage?: Error0.GeneralProps['clientMessage']
66
56
  static defaultMeta?: Meta0.Meta0OrValueTypeNullish
67
57
 
68
- public readonly propsOriginal: Error0GeneralProps
58
+ public readonly propsOriginal: Error0.GeneralProps
69
59
 
70
60
  constructor(message: string)
71
- constructor(input: Error0Input)
72
- constructor(message: string, input: Error0Input)
61
+ constructor(input: Error0.Input)
62
+ constructor(message: string, input: Error0.Input)
73
63
  constructor(error: Error)
74
- constructor(error: Error, input: Error0Input)
64
+ constructor(error: Error, input: Error0.Input)
75
65
  constructor(value: unknown)
76
- constructor(value: unknown, input: Error0Input)
66
+ constructor(value: unknown, input: Error0.Input)
77
67
  constructor(...args: unknown[]) {
78
- const input: Partial<Error0Input> = {}
68
+ const input: Partial<Error0.Input> = {}
79
69
  if (args[0] instanceof Error) {
80
70
  input.cause = args[0]
81
71
  } else if (typeof args[0] === 'object' && args[0] !== null) {
@@ -121,8 +111,8 @@ export class Error0 extends Error {
121
111
 
122
112
  // props
123
113
 
124
- public static _safeParseInput(error0Input: Record<string, unknown>): Error0Input {
125
- const result: Error0Input = {}
114
+ public static _safeParseInput(error0Input: Record<string, unknown>): Error0.Input {
115
+ const result: Error0.Input = {}
126
116
  result.message = typeof error0Input.message === 'string' ? error0Input.message : undefined
127
117
  result.tag = typeof error0Input.tag === 'string' ? error0Input.tag : undefined
128
118
  result.code = typeof error0Input.code === 'string' ? error0Input.code : undefined
@@ -159,19 +149,27 @@ export class Error0 extends Error {
159
149
  message,
160
150
  stack,
161
151
  }: {
162
- error0Input: Error0Input
152
+ error0Input: Error0.Input
163
153
  message: string
164
- stack: Error0GeneralProps['stack']
165
- }): Error0GeneralProps {
154
+ stack: Error0.GeneralProps['stack']
155
+ }): Error0.GeneralProps {
166
156
  // const meta = Meta0.merge(error0Input.meta0, error0Input.meta).value
167
- const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta)
157
+
158
+ // const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta)
159
+ // const defaultMetaValue =
160
+ // this.defaultMeta && typeof this.defaultMeta === 'object' && 'getValue' in this.defaultMeta
161
+ // ? (this.defaultMeta as any).getValue()
162
+ // : this.defaultMeta
163
+
164
+ const meta0 = Meta0.extend(this.defaultMeta, error0Input.meta)
168
165
  const meta = meta0.getValue()
169
- const finalTag = meta0.getFinalTag(error0Input.tag)
166
+ const finalTag = meta0PluginTag.public.getFullTag(meta0, error0Input.tag)
167
+ delete meta.tagPrefix
170
168
  const clientMessage = error0Input.clientMessage || this.defaultClientMessage
171
- const result: Error0GeneralProps = {
169
+ const result: Error0.GeneralProps = {
172
170
  message: error0Input.message || this.defaultMessage,
173
171
  tag: finalTag,
174
- code: error0Input.code || meta.code || this.defaultCode,
172
+ code: error0Input.code || toStringOrUndefined(meta.code) || this.defaultCode,
175
173
  httpStatus:
176
174
  typeof error0Input.httpStatus === 'number'
177
175
  ? error0Input.httpStatus
@@ -179,7 +177,7 @@ export class Error0 extends Error {
179
177
  typeof error0Input.httpStatus === 'string' &&
180
178
  error0Input.httpStatus in HttpStatusCode
181
179
  ? HttpStatusCode[error0Input.httpStatus]
182
- : meta.httpStatus || this.defaultHttpStatus,
180
+ : toNumberOrUndefined(meta.httpStatus) || this.defaultHttpStatus,
183
181
  expected: undefined,
184
182
  clientMessage,
185
183
  anyMessage: clientMessage || message,
@@ -193,19 +191,19 @@ export class Error0 extends Error {
193
191
  result,
194
192
  typeof error0Input.expected === 'boolean' || typeof error0Input.expected === 'function'
195
193
  ? error0Input.expected
196
- : meta.expected || this.defaultExpected,
194
+ : toBooleanOrUndefined(meta.expected) || this.defaultExpected,
197
195
  )
198
196
  result.stack = this._removeConstructorStackPart(stack)
199
197
  return result
200
198
  }
201
199
 
202
- public static _getSelfPropsFloated(causesProps: Error0GeneralProps[]): Error0GeneralProps {
200
+ public static _getSelfPropsFloated(causesProps: Error0.GeneralProps[]): Error0.GeneralProps {
203
201
  const cause = this._getClosestPropValue(causesProps, 'cause')
204
202
  const stack = this._mergeStack(causesProps[1]?.stack, causesProps[0]?.stack)
205
203
  const closestTag = this._getClosestPropValue(causesProps, 'tag')
206
204
  const meta = this._getMergedMetaValue(causesProps)
207
- const tag = Meta0.getFinalTag(meta, closestTag)
208
- const propsFloated: Error0GeneralProps = {
205
+ const tag = meta0PluginTag.public.getFullTag(meta, closestTag)
206
+ const propsFloated: Error0.GeneralProps = {
209
207
  message: this._getClosestPropValue(causesProps, 'message'),
210
208
  tag,
211
209
  code: this._getClosestPropValue(causesProps, 'code'),
@@ -224,13 +222,13 @@ export class Error0 extends Error {
224
222
 
225
223
  // sepcial
226
224
 
227
- public static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0GeneralProps> {
225
+ public static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0.GeneralProps> {
228
226
  return {
229
227
  message: `Zod Validation Error: ${zodError.message}`,
230
228
  }
231
229
  }
232
230
 
233
- public static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0GeneralProps> {
231
+ public static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0.GeneralProps> {
234
232
  return {
235
233
  message: 'Axios Error',
236
234
  meta: {
@@ -247,8 +245,8 @@ export class Error0 extends Error {
247
245
  }
248
246
 
249
247
  public static _assignError0Props(
250
- error0Props: Error0GeneralProps,
251
- extraError0Props: Partial<Error0GeneralProps>,
248
+ error0Props: Error0.GeneralProps,
249
+ extraError0Props: Partial<Error0.GeneralProps>,
252
250
  ): void {
253
251
  const metaValue = Meta0.mergeValues(error0Props.meta, extraError0Props.meta)
254
252
  Object.assign(error0Props, extraError0Props, { meta: metaValue })
@@ -257,8 +255,8 @@ export class Error0 extends Error {
257
255
  // expected
258
256
 
259
257
  public static _normalizeSelfExpected(
260
- error0Props: Error0GeneralProps,
261
- expectedProvided: Error0Input['expected'],
258
+ error0Props: Error0.GeneralProps,
259
+ expectedProvided: Error0.Input['expected'],
262
260
  ): boolean | undefined {
263
261
  if (typeof expectedProvided === 'function') {
264
262
  return expectedProvided(error0Props)
@@ -266,7 +264,7 @@ export class Error0 extends Error {
266
264
  return expectedProvided
267
265
  }
268
266
 
269
- public static _isExpected(causesProps: Error0GeneralProps[]): boolean {
267
+ public static _isExpected(causesProps: Error0.GeneralProps[]): boolean {
270
268
  let hasExpectedTrue = false
271
269
  for (const causeProps of causesProps) {
272
270
  if (causeProps.expected === false) {
@@ -281,7 +279,7 @@ export class Error0 extends Error {
281
279
 
282
280
  // getters
283
281
 
284
- public static _getPropsFromUnknown(error: unknown, defaults?: Error0Input): Error0GeneralProps {
282
+ public static _getPropsFromUnknown(error: unknown, defaults?: Error0.Input): Error0.GeneralProps {
285
283
  if (typeof error !== 'object' || error === null) {
286
284
  return {
287
285
  message: undefined,
@@ -303,7 +301,7 @@ export class Error0 extends Error {
303
301
  'clientMessage' in error && typeof error.clientMessage === 'string'
304
302
  ? error.clientMessage
305
303
  : defaults?.clientMessage || undefined
306
- const result: Error0GeneralProps = {
304
+ const result: Error0.GeneralProps = {
307
305
  message,
308
306
  code: 'code' in error && typeof error.code === 'string' ? error.code : defaults?.code || undefined,
309
307
  clientMessage,
@@ -315,7 +313,8 @@ export class Error0 extends Error {
315
313
  meta:
316
314
  'meta' in error && typeof error.meta === 'object' && error.meta !== null
317
315
  ? Meta0.getValue(error.meta as Meta0.ValueType)
318
- : Meta0.getValue(defaults?.meta) || {},
316
+ : // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
317
+ Meta0.getValue(defaults?.meta) || {},
319
318
  httpStatus:
320
319
  'httpStatus' in error && typeof error.httpStatus === 'number' && error.httpStatus in HttpStatusCode
321
320
  ? error.httpStatus
@@ -338,7 +337,7 @@ export class Error0 extends Error {
338
337
  result.expected = this._normalizeSelfExpected(
339
338
  result,
340
339
  'expected' in error && (typeof error.expected === 'boolean' || typeof error.expected === 'function')
341
- ? (error.expected as ExpectedFn)
340
+ ? (error.expected as Error0.ExpectedFn)
342
341
  : defaults?.expected || undefined,
343
342
  )
344
343
  if (result.zodError) {
@@ -350,12 +349,12 @@ export class Error0 extends Error {
350
349
  return result
351
350
  }
352
351
 
353
- public static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0GeneralProps[] {
352
+ public static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[] {
354
353
  if (!error) {
355
354
  return []
356
355
  }
357
356
  const causeProps = this._getPropsFromUnknown(error)
358
- const causesProps: Error0GeneralProps[] = [causeProps]
357
+ const causesProps: Error0.GeneralProps[] = [causeProps]
359
358
  if (!causeProps.cause) {
360
359
  return causesProps
361
360
  }
@@ -366,28 +365,28 @@ export class Error0 extends Error {
366
365
  }
367
366
 
368
367
  public static _getCausesPropsFromError0Props(
369
- error0Props: Error0GeneralProps,
368
+ error0Props: Error0.GeneralProps,
370
369
  maxLevel: number,
371
- ): Error0GeneralProps[] {
370
+ ): Error0.GeneralProps[] {
372
371
  return [error0Props, ...this._getCausesPropsFromUnknown(error0Props.cause, maxLevel - 1)]
373
372
  }
374
373
 
375
- public static _getClosestPropValue<TPropKey extends keyof Error0GeneralProps>(
376
- causesProps: Error0GeneralProps[],
374
+ public static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(
375
+ causesProps: Error0.GeneralProps[],
377
376
  propKey: TPropKey,
378
- ): NonNullable<Error0GeneralProps[TPropKey]> | undefined {
377
+ ): NonNullable<Error0.GeneralProps[TPropKey]> | undefined {
379
378
  for (const causeProps of causesProps) {
380
379
  const propValue = causeProps[propKey]
381
380
  if (isFilled(propValue)) {
382
- return propValue as NonNullable<Error0GeneralProps[TPropKey]>
381
+ return propValue
383
382
  }
384
383
  }
385
384
  return undefined
386
385
  }
387
386
 
388
387
  // private static getClosestByGetter<TResult>(
389
- // causesProps: Error0GeneralProps[],
390
- // getter: (props: Error0GeneralProps) => TResult,
388
+ // causesProps: Error0.GeneralProps[],
389
+ // getter: (props: Error0.GeneralProps) => TResult,
391
390
  // ): NonNullable<TResult> | undefined {
392
391
  // for (const causeProps of causesProps) {
393
392
  // const result = getter(causeProps)
@@ -398,21 +397,21 @@ export class Error0 extends Error {
398
397
  // return undefined
399
398
  // }
400
399
 
401
- public static _getFilledPropValues<TPropKey extends keyof Error0Input>(
402
- causesProps: Error0GeneralProps[],
400
+ public static _getFilledPropValues<TPropKey extends keyof Error0.Input>(
401
+ causesProps: Error0.GeneralProps[],
403
402
  propKey: TPropKey,
404
- ): NonNullable<Error0GeneralProps[TPropKey]>[] {
405
- const values: NonNullable<Error0GeneralProps[TPropKey]>[] = []
403
+ ): Array<NonNullable<Error0.GeneralProps[TPropKey]>> {
404
+ const values: Array<NonNullable<Error0.GeneralProps[TPropKey]>> = []
406
405
  for (const causeProps of causesProps) {
407
406
  const propValue = causeProps[propKey]
408
407
  if (isFilled(propValue)) {
409
- values.push(propValue as NonNullable<Error0GeneralProps[TPropKey]>)
408
+ values.push(propValue)
410
409
  }
411
410
  }
412
411
  return values
413
412
  }
414
413
 
415
- public static _getMergedMetaValue(causesProps: Error0GeneralProps[]): Meta0.ValueType {
414
+ public static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType {
416
415
  const metas = this._getFilledPropValues(causesProps, 'meta')
417
416
  if (metas.length === 0) {
418
417
  return {}
@@ -425,7 +424,7 @@ export class Error0 extends Error {
425
424
 
426
425
  // stack
427
426
 
428
- public static _removeConstructorStackPart(stack: Error0GeneralProps['stack']): Error0GeneralProps['stack'] {
427
+ public static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'] {
429
428
  if (!stack) {
430
429
  return stack
431
430
  }
@@ -441,9 +440,9 @@ export class Error0 extends Error {
441
440
  }
442
441
 
443
442
  public static _mergeStack(
444
- prevStack: Error0GeneralProps['stack'],
445
- nextStack: Error0GeneralProps['stack'],
446
- ): Error0GeneralProps['stack'] {
443
+ prevStack: Error0.GeneralProps['stack'],
444
+ nextStack: Error0.GeneralProps['stack'],
445
+ ): Error0.GeneralProps['stack'] {
447
446
  return [nextStack, prevStack].filter(Boolean).join('\n\n') || undefined
448
447
  }
449
448
 
@@ -467,7 +466,7 @@ export class Error0 extends Error {
467
466
  return false
468
467
  }
469
468
 
470
- public static _toError0(error: unknown, inputOverride: Error0Input = {}): Error0 {
469
+ public static _toError0(error: unknown, inputOverride: Error0.Input = {}): Error0 {
471
470
  if (error instanceof Error0) {
472
471
  return error
473
472
  }
@@ -483,14 +482,18 @@ export class Error0 extends Error {
483
482
  })
484
483
  }
485
484
 
486
- const inputFromData = get(error, 'data')
485
+ // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
486
+ const inputFromData = get(error, 'data', undefined)
487
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
487
488
  if (inputFromData) {
488
489
  if (Error0.isLikelyError0(inputFromData)) {
489
490
  return this._toError0(inputFromData, inputOverride)
490
491
  }
491
492
  }
492
493
 
493
- const inputFromDataError0 = get(error, 'data.error0')
494
+ // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
495
+ const inputFromDataError0 = get(error, 'data.error0', undefined)
496
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
494
497
  if (inputFromDataError0) {
495
498
  if (Error0.isLikelyError0(inputFromDataError0)) {
496
499
  return this._toError0(inputFromDataError0, inputOverride)
@@ -500,18 +503,19 @@ export class Error0 extends Error {
500
503
  return new Error0(this._getPropsFromUnknown(error, inputOverride))
501
504
  }
502
505
 
503
- static from(error: unknown, inputOverride?: Error0Input): Error0 {
506
+ static from(error: unknown, inputOverride?: Error0.Input): Error0 {
504
507
  return this._toError0(error, inputOverride)
505
508
  }
506
509
 
507
510
  static extend(props: {
508
- defaultMessage?: Error0GeneralProps['message']
509
- defaultCode?: Error0GeneralProps['code']
510
- defaultHttpStatus?: Error0GeneralProps['httpStatus']
511
- defaultExpected?: Error0GeneralProps['expected']
512
- defaultClientMessage?: Error0GeneralProps['clientMessage']
511
+ defaultMessage?: Error0.GeneralProps['message']
512
+ defaultCode?: Error0.GeneralProps['code']
513
+ defaultHttpStatus?: Error0.GeneralProps['httpStatus']
514
+ defaultExpected?: Error0.GeneralProps['expected']
515
+ defaultClientMessage?: Error0.GeneralProps['clientMessage']
513
516
  defaultMeta?: Meta0.Meta0OrValueTypeNullish
514
517
  }) {
518
+ // eslint-disable-next-line consistent-this, @typescript-eslint/no-this-alias
515
519
  const parent = this
516
520
  return class Error0 extends parent {
517
521
  static override defaultMessage = props.defaultMessage ?? parent.defaultMessage
@@ -519,18 +523,18 @@ export class Error0 extends Error {
519
523
  static override defaultHttpStatus = props.defaultHttpStatus ?? parent.defaultHttpStatus
520
524
  static override defaultExpected = props.defaultExpected ?? parent.defaultExpected
521
525
  static override defaultClientMessage = props.defaultClientMessage ?? parent.defaultClientMessage
522
- static override defaultMeta = Meta0.extend(props.defaultMeta, parent.defaultMeta)
526
+ static override defaultMeta = Meta0.extend(parent.defaultMeta, props.defaultMeta)
523
527
  }
524
528
  }
525
529
 
526
530
  static extendCollection<T extends Record<string, typeof Error0>>(
527
531
  classes: T,
528
532
  props: {
529
- defaultMessage?: Error0GeneralProps['message']
530
- defaultCode?: Error0GeneralProps['code']
531
- defaultHttpStatus?: Error0GeneralProps['httpStatus']
532
- defaultExpected?: Error0GeneralProps['expected']
533
- defaultClientMessage?: Error0GeneralProps['clientMessage']
533
+ defaultMessage?: Error0.GeneralProps['message']
534
+ defaultCode?: Error0.GeneralProps['code']
535
+ defaultHttpStatus?: Error0.GeneralProps['httpStatus']
536
+ defaultExpected?: Error0.GeneralProps['expected']
537
+ defaultClientMessage?: Error0.GeneralProps['clientMessage']
534
538
  defaultMeta?: Meta0.Meta0OrValueTypeNullish
535
539
  },
536
540
  ): T {
@@ -552,7 +556,7 @@ export class Error0 extends Error {
552
556
  __I_AM_ERROR_0: this.__I_AM_ERROR_0,
553
557
  }
554
558
  }
555
- static toJSON(error: unknown, inputOverride?: Error0Input) {
559
+ static toJSON(error: unknown, inputOverride?: Error0.Input) {
556
560
  const error0 = this.from(error, inputOverride)
557
561
  return error0.toJSON()
558
562
  }
@@ -572,13 +576,38 @@ export class Error0 extends Error {
572
576
  }
573
577
 
574
578
  export namespace Error0 {
579
+ export interface Input {
580
+ message?: string
581
+ tag?: string
582
+ code?: string
583
+ httpStatus?: HttpStatusCode | HttpStatusCodeString
584
+ expected?: boolean | ExpectedFn
585
+ clientMessage?: string
586
+ cause?: Error0Cause
587
+ stack?: string
588
+ meta?: Meta0.Meta0OrValueTypeNullish
589
+ zodError?: ZodError
590
+ axiosError?: AxiosError
591
+ }
592
+
593
+ export interface GeneralProps {
594
+ message: Input['message']
595
+ tag: Input['tag']
596
+ code: Input['code']
597
+ httpStatus: number | undefined
598
+ expected: boolean | undefined
599
+ clientMessage: Input['clientMessage']
600
+ anyMessage: string | undefined
601
+ cause: Input['cause']
602
+ stack: Error['stack']
603
+ meta: Meta0.ValueType
604
+ zodError?: ZodError
605
+ axiosError?: AxiosError
606
+ }
607
+
608
+ export type HttpStatusCodeString = keyof typeof HttpStatusCode
609
+ export type Error0Cause = unknown
610
+ export type ExpectedFn = (error: GeneralProps) => boolean | undefined
575
611
  export type JSON = ReturnType<Error0['toJSON']>
576
612
  export type Collection = Record<string, typeof Error0>
577
613
  }
578
-
579
- export const e0s = {
580
- Default: Error0,
581
- Expected: Error0.extend({
582
- defaultExpected: true,
583
- }) as typeof Error0,
584
- } satisfies Error0.Collection