@cobol-ts/errors 0.0.3 → 0.0.5
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/dist/index.js.map +1 -0
- package/dist/src/error.monad.d.ts +156 -0
- package/dist/src/error.monad.js +208 -0
- package/dist/src/error.monad.js.map +1 -0
- package/dist/src/error.monad.spec.d.ts +1 -0
- package/dist/src/error.monad.spec.js +179 -0
- package/dist/src/error.monad.spec.js.map +1 -0
- package/dist/src/error.report.d.ts +2 -0
- package/dist/src/error.report.js +3 -0
- package/dist/src/error.report.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,qDAAkC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { NameAnd } from "@cobol-ts/records";
|
|
2
|
+
/**
|
|
3
|
+
* Represents either a successful value of type T or a set of errors.
|
|
4
|
+
* @template T - The type of the successful value.
|
|
5
|
+
*/
|
|
6
|
+
export type ErrorsOr<T> = Errors | Value<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a successful value.
|
|
9
|
+
* @template T - The type of the wrapped value.
|
|
10
|
+
*/
|
|
11
|
+
export type Value<T> = {
|
|
12
|
+
value: T;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Represents one or more error messages, with optional debugging metadata.
|
|
16
|
+
*/
|
|
17
|
+
export type Errors = {
|
|
18
|
+
/** The list of error messages. */
|
|
19
|
+
errors: string[];
|
|
20
|
+
/** Optional reference identifier for debugging. */
|
|
21
|
+
reference?: string;
|
|
22
|
+
/** Optional extra context or metadata. */
|
|
23
|
+
extras?: any;
|
|
24
|
+
};
|
|
25
|
+
export declare const value: <T>(t: T) => ErrorsOr<T>;
|
|
26
|
+
export declare const errors: (...es: string[]) => ErrorsOr<never>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates an Errors object from an exception or unknown error.
|
|
29
|
+
* @param context - A string describing the context where the error occurred.
|
|
30
|
+
* @param err - The caught error or any thrown value.
|
|
31
|
+
* @param extras - Optional additional metadata.
|
|
32
|
+
* @returns An Errors object containing a formatted message and extras.
|
|
33
|
+
*/
|
|
34
|
+
export declare function makeErrorFromException(context: string, err: unknown, extras?: any): Errors;
|
|
35
|
+
/**
|
|
36
|
+
* Exception type used to throw structured error lists.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ErrorsException extends Error {
|
|
39
|
+
errors: string[];
|
|
40
|
+
reference?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* @param errors - The array of error messages.
|
|
43
|
+
* @param reference - Optional reference ID for debugging.
|
|
44
|
+
*/
|
|
45
|
+
constructor(errors: string[], reference?: string | undefined);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Type guard to check if an ErrorsOr contains a value.
|
|
49
|
+
* @param e - The ErrorsOr to inspect.
|
|
50
|
+
* @returns True if e contains a value, false if it contains errors.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isValue<T>(e: ErrorsOr<T>): e is Value<T>;
|
|
53
|
+
/**
|
|
54
|
+
* Type guard to check if an ErrorsOr contains errors.
|
|
55
|
+
* @param e - The ErrorsOr to inspect.
|
|
56
|
+
* @returns True if e contains errors, false if it contains a value.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isErrors(e: unknown): e is Errors;
|
|
59
|
+
/**
|
|
60
|
+
* Extracts the wrapped value or throws an ErrorsException if errors are present.
|
|
61
|
+
* @param e - The ErrorsOr to unwrap.
|
|
62
|
+
* @throws {ErrorsException} When e contains errors.
|
|
63
|
+
* @returns The unwrapped value of type T.
|
|
64
|
+
*/
|
|
65
|
+
export declare function valueOrThrow<T>(e: ErrorsOr<T>): T;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the wrapped value, a default if errors exist or if the value is null/undefined.
|
|
68
|
+
* @param e - The ErrorsOr to inspect.
|
|
69
|
+
* @param defaultValue - The default to return on errors or nullish values.
|
|
70
|
+
* @returns The wrapped value or defaultValue.
|
|
71
|
+
*/
|
|
72
|
+
export declare const valueOrDefault: <T>(e: ErrorsOr<T>, defaultValue: T) => T;
|
|
73
|
+
/**
|
|
74
|
+
* Splits a record of named ErrorsOr<T> into its successful values and aggregated errors.
|
|
75
|
+
* @template T - The type of the successful values.
|
|
76
|
+
* @param es - An object mapping names to ErrorsOr<T>.
|
|
77
|
+
* @returns An object containing two properties:
|
|
78
|
+
* - values: A record of names to unwrapped T values.
|
|
79
|
+
* - errors: A flat array of all error messages.
|
|
80
|
+
*/
|
|
81
|
+
export declare function partitionNameAndErrorsOr<T>(es: NameAnd<ErrorsOr<T>>): {
|
|
82
|
+
values: NameAnd<T>;
|
|
83
|
+
errors: string[];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Extracts errors or throws if a value is present unexpectedly.
|
|
87
|
+
* @param e - The ErrorsOr to inspect.
|
|
88
|
+
* @throws {ErrorsException} When e contains a value.
|
|
89
|
+
* @returns The array of error messages.
|
|
90
|
+
*/
|
|
91
|
+
export declare function errorsOrThrow<T>(e: ErrorsOr<T>): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Extracts the Errors object or throws if a value is present unexpectedly.
|
|
94
|
+
* @param e - The ErrorsOr to inspect.
|
|
95
|
+
* @throws {ErrorsException} When e contains a value.
|
|
96
|
+
* @returns The Errors object.
|
|
97
|
+
*/
|
|
98
|
+
export declare function errorObjectOrThrow<T>(e: ErrorsOr<T>): Errors;
|
|
99
|
+
/**
|
|
100
|
+
* Applies a transform function to the wrapped value, preserving errors.
|
|
101
|
+
* @template T - Original value type.
|
|
102
|
+
* @template T1 - Transformed value type.
|
|
103
|
+
* @param e - The ErrorsOr to map.
|
|
104
|
+
* @param f - Function to apply if a value is present.
|
|
105
|
+
* @returns A new ErrorsOr containing either the transformed value or the original errors.
|
|
106
|
+
*/
|
|
107
|
+
export declare function mapErrorsOr<T, T1>(e: ErrorsOr<T>, f: (t: T) => T1): ErrorsOr<T1>;
|
|
108
|
+
/**
|
|
109
|
+
* Applies a transform that returns ErrorsOr to the wrapped value, flattening the result.
|
|
110
|
+
* @template T - Original value type.
|
|
111
|
+
* @template T1 - Resulting value type.
|
|
112
|
+
* @param e - The ErrorsOr to flatMap.
|
|
113
|
+
* @param f - Function to apply if a value is present.
|
|
114
|
+
* @returns The result of f(e.value) or the original errors.
|
|
115
|
+
*/
|
|
116
|
+
export declare function flatMapErrorsOr<T, T1>(e: ErrorsOr<T>, f: (t: T) => ErrorsOr<T1>): ErrorsOr<T1>;
|
|
117
|
+
/**
|
|
118
|
+
* Asynchronously transforms the wrapped value, preserving errors.
|
|
119
|
+
* @template T - Original value type.
|
|
120
|
+
* @template T1 - Transformed value type.
|
|
121
|
+
* @param e - The ErrorsOr to map.
|
|
122
|
+
* @param f - Async function to apply if a value is present.
|
|
123
|
+
* @returns A promise resolving to a new ErrorsOr of the transformed value or original errors.
|
|
124
|
+
*/
|
|
125
|
+
export declare function mapErrorsOrK<T, T1>(e: ErrorsOr<T>, f: (t: T) => Promise<T1>): Promise<ErrorsOr<T1>>;
|
|
126
|
+
/**
|
|
127
|
+
* Asynchronously flatMaps the wrapped value, flattening nested ErrorsOr.
|
|
128
|
+
* @template T - Original value type.
|
|
129
|
+
* @template T1 - Resulting value type.
|
|
130
|
+
* @param e - The ErrorsOr to flatMap.
|
|
131
|
+
* @param f - Async function returning ErrorsOr to apply if a value is present.
|
|
132
|
+
* @returns A promise resolving to ErrorsOr<T1>.
|
|
133
|
+
*/
|
|
134
|
+
export declare function flatMapErrorsOrK<T, T1>(e: ErrorsOr<T>, f: (t: T) => Promise<ErrorsOr<T1>>): Promise<ErrorsOr<T1>>;
|
|
135
|
+
/**
|
|
136
|
+
* Recovers from errors by applying a fallback function, or returns the value if present.
|
|
137
|
+
* @template T - The value type.
|
|
138
|
+
* @param e - The ErrorsOr to recover.
|
|
139
|
+
* @param f - Function to produce a fallback value from the Errors.
|
|
140
|
+
* @returns The original value or the fallback.
|
|
141
|
+
*/
|
|
142
|
+
export declare function recover<T>(e: ErrorsOr<T>, f: (e: Errors) => T): T;
|
|
143
|
+
/**
|
|
144
|
+
* Represents an asynchronous function from a single input to an ErrorsOr result.
|
|
145
|
+
* @template From - Input parameter type.
|
|
146
|
+
* @template To - Output result type.
|
|
147
|
+
*/
|
|
148
|
+
export type AsyncErrorCall<From, To> = (from: From) => Promise<ErrorsOr<To>>;
|
|
149
|
+
/**
|
|
150
|
+
* Represents an asynchronous function from two inputs to an ErrorsOr result.
|
|
151
|
+
* @template From1 - First input parameter type.
|
|
152
|
+
* @template From2 - Second input parameter type.
|
|
153
|
+
* @template To - Output result type.
|
|
154
|
+
*/
|
|
155
|
+
export type AsyncErrorCall2<From1, From2, To> = (from1: From1, from2: From2) => Promise<ErrorsOr<To>>;
|
|
156
|
+
export declare function flattenArrayOfErrorsOr<T>(es: ErrorsOr<T>[]): ErrorsOr<T[]>;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.valueOrDefault = exports.ErrorsException = exports.errors = exports.value = void 0;
|
|
4
|
+
exports.makeErrorFromException = makeErrorFromException;
|
|
5
|
+
exports.isValue = isValue;
|
|
6
|
+
exports.isErrors = isErrors;
|
|
7
|
+
exports.valueOrThrow = valueOrThrow;
|
|
8
|
+
exports.partitionNameAndErrorsOr = partitionNameAndErrorsOr;
|
|
9
|
+
exports.errorsOrThrow = errorsOrThrow;
|
|
10
|
+
exports.errorObjectOrThrow = errorObjectOrThrow;
|
|
11
|
+
exports.mapErrorsOr = mapErrorsOr;
|
|
12
|
+
exports.flatMapErrorsOr = flatMapErrorsOr;
|
|
13
|
+
exports.mapErrorsOrK = mapErrorsOrK;
|
|
14
|
+
exports.flatMapErrorsOrK = flatMapErrorsOrK;
|
|
15
|
+
exports.recover = recover;
|
|
16
|
+
exports.flattenArrayOfErrorsOr = flattenArrayOfErrorsOr;
|
|
17
|
+
const value = (t) => ({ value: t });
|
|
18
|
+
exports.value = value;
|
|
19
|
+
const errors = (...es) => ({ errors: es });
|
|
20
|
+
exports.errors = errors;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an Errors object from an exception or unknown error.
|
|
23
|
+
* @param context - A string describing the context where the error occurred.
|
|
24
|
+
* @param err - The caught error or any thrown value.
|
|
25
|
+
* @param extras - Optional additional metadata.
|
|
26
|
+
* @returns An Errors object containing a formatted message and extras.
|
|
27
|
+
*/
|
|
28
|
+
function makeErrorFromException(context, err, extras) {
|
|
29
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
30
|
+
return { errors: [`${context} error ${message}`], extras };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Exception type used to throw structured error lists.
|
|
34
|
+
*/
|
|
35
|
+
class ErrorsException extends Error {
|
|
36
|
+
errors;
|
|
37
|
+
reference;
|
|
38
|
+
/**
|
|
39
|
+
* @param errors - The array of error messages.
|
|
40
|
+
* @param reference - Optional reference ID for debugging.
|
|
41
|
+
*/
|
|
42
|
+
constructor(errors, reference) {
|
|
43
|
+
super(errors.join(', '));
|
|
44
|
+
this.errors = errors;
|
|
45
|
+
this.reference = reference;
|
|
46
|
+
this.name = 'ErrorsException';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ErrorsException = ErrorsException;
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if an ErrorsOr contains a value.
|
|
52
|
+
* @param e - The ErrorsOr to inspect.
|
|
53
|
+
* @returns True if e contains a value, false if it contains errors.
|
|
54
|
+
*/
|
|
55
|
+
function isValue(e) {
|
|
56
|
+
return 'value' in e;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check if an ErrorsOr contains errors.
|
|
60
|
+
* @param e - The ErrorsOr to inspect.
|
|
61
|
+
* @returns True if e contains errors, false if it contains a value.
|
|
62
|
+
*/
|
|
63
|
+
function isErrors(e) {
|
|
64
|
+
return (typeof e === "object" && e !== null && "errors" in e);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Extracts the wrapped value or throws an ErrorsException if errors are present.
|
|
68
|
+
* @param e - The ErrorsOr to unwrap.
|
|
69
|
+
* @throws {ErrorsException} When e contains errors.
|
|
70
|
+
* @returns The unwrapped value of type T.
|
|
71
|
+
*/
|
|
72
|
+
function valueOrThrow(e) {
|
|
73
|
+
if (isErrors(e))
|
|
74
|
+
throw new ErrorsException(e.errors, e.reference);
|
|
75
|
+
return e.value;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the wrapped value, a default if errors exist or if the value is null/undefined.
|
|
79
|
+
* @param e - The ErrorsOr to inspect.
|
|
80
|
+
* @param defaultValue - The default to return on errors or nullish values.
|
|
81
|
+
* @returns The wrapped value or defaultValue.
|
|
82
|
+
*/
|
|
83
|
+
const valueOrDefault = (e, defaultValue) => {
|
|
84
|
+
if (isErrors(e))
|
|
85
|
+
return defaultValue;
|
|
86
|
+
const value = e?.value;
|
|
87
|
+
return value === null || value === undefined ? defaultValue : value;
|
|
88
|
+
};
|
|
89
|
+
exports.valueOrDefault = valueOrDefault;
|
|
90
|
+
/**
|
|
91
|
+
* Splits a record of named ErrorsOr<T> into its successful values and aggregated errors.
|
|
92
|
+
* @template T - The type of the successful values.
|
|
93
|
+
* @param es - An object mapping names to ErrorsOr<T>.
|
|
94
|
+
* @returns An object containing two properties:
|
|
95
|
+
* - values: A record of names to unwrapped T values.
|
|
96
|
+
* - errors: A flat array of all error messages.
|
|
97
|
+
*/
|
|
98
|
+
function partitionNameAndErrorsOr(es) {
|
|
99
|
+
const values = {};
|
|
100
|
+
const errors = [];
|
|
101
|
+
for (const [name, value] of Object.entries(es)) {
|
|
102
|
+
if (isValue(value))
|
|
103
|
+
values[name] = value.value;
|
|
104
|
+
else
|
|
105
|
+
errors.push(...value.errors);
|
|
106
|
+
}
|
|
107
|
+
return { values, errors };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Extracts errors or throws if a value is present unexpectedly.
|
|
111
|
+
* @param e - The ErrorsOr to inspect.
|
|
112
|
+
* @throws {ErrorsException} When e contains a value.
|
|
113
|
+
* @returns The array of error messages.
|
|
114
|
+
*/
|
|
115
|
+
function errorsOrThrow(e) {
|
|
116
|
+
if (isValue(e))
|
|
117
|
+
throw new ErrorsException([
|
|
118
|
+
`Expected errors but got value ${JSON.stringify(e)}`,
|
|
119
|
+
]);
|
|
120
|
+
return e.errors;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Extracts the Errors object or throws if a value is present unexpectedly.
|
|
124
|
+
* @param e - The ErrorsOr to inspect.
|
|
125
|
+
* @throws {ErrorsException} When e contains a value.
|
|
126
|
+
* @returns The Errors object.
|
|
127
|
+
*/
|
|
128
|
+
function errorObjectOrThrow(e) {
|
|
129
|
+
if (isValue(e))
|
|
130
|
+
throw new ErrorsException([
|
|
131
|
+
`Expected errors but got value ${JSON.stringify(e)}`,
|
|
132
|
+
]);
|
|
133
|
+
return e;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Applies a transform function to the wrapped value, preserving errors.
|
|
137
|
+
* @template T - Original value type.
|
|
138
|
+
* @template T1 - Transformed value type.
|
|
139
|
+
* @param e - The ErrorsOr to map.
|
|
140
|
+
* @param f - Function to apply if a value is present.
|
|
141
|
+
* @returns A new ErrorsOr containing either the transformed value or the original errors.
|
|
142
|
+
*/
|
|
143
|
+
function mapErrorsOr(e, f) {
|
|
144
|
+
if (isValue(e))
|
|
145
|
+
return { value: f(e.value) };
|
|
146
|
+
return e;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Applies a transform that returns ErrorsOr to the wrapped value, flattening the result.
|
|
150
|
+
* @template T - Original value type.
|
|
151
|
+
* @template T1 - Resulting value type.
|
|
152
|
+
* @param e - The ErrorsOr to flatMap.
|
|
153
|
+
* @param f - Function to apply if a value is present.
|
|
154
|
+
* @returns The result of f(e.value) or the original errors.
|
|
155
|
+
*/
|
|
156
|
+
function flatMapErrorsOr(e, f) {
|
|
157
|
+
if (isValue(e))
|
|
158
|
+
return f(e.value);
|
|
159
|
+
return e;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Asynchronously transforms the wrapped value, preserving errors.
|
|
163
|
+
* @template T - Original value type.
|
|
164
|
+
* @template T1 - Transformed value type.
|
|
165
|
+
* @param e - The ErrorsOr to map.
|
|
166
|
+
* @param f - Async function to apply if a value is present.
|
|
167
|
+
* @returns A promise resolving to a new ErrorsOr of the transformed value or original errors.
|
|
168
|
+
*/
|
|
169
|
+
function mapErrorsOrK(e, f) {
|
|
170
|
+
return isValue(e) ? f(e.value).then((v) => ({ value: v })) : Promise.resolve(e);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Asynchronously flatMaps the wrapped value, flattening nested ErrorsOr.
|
|
174
|
+
* @template T - Original value type.
|
|
175
|
+
* @template T1 - Resulting value type.
|
|
176
|
+
* @param e - The ErrorsOr to flatMap.
|
|
177
|
+
* @param f - Async function returning ErrorsOr to apply if a value is present.
|
|
178
|
+
* @returns A promise resolving to ErrorsOr<T1>.
|
|
179
|
+
*/
|
|
180
|
+
function flatMapErrorsOrK(e, f) {
|
|
181
|
+
return isValue(e)
|
|
182
|
+
? f(e.value)
|
|
183
|
+
: Promise.resolve(e);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Recovers from errors by applying a fallback function, or returns the value if present.
|
|
187
|
+
* @template T - The value type.
|
|
188
|
+
* @param e - The ErrorsOr to recover.
|
|
189
|
+
* @param f - Function to produce a fallback value from the Errors.
|
|
190
|
+
* @returns The original value or the fallback.
|
|
191
|
+
*/
|
|
192
|
+
function recover(e, f) {
|
|
193
|
+
if (isErrors(e))
|
|
194
|
+
return f(e);
|
|
195
|
+
return e.value;
|
|
196
|
+
}
|
|
197
|
+
function flattenArrayOfErrorsOr(es) {
|
|
198
|
+
const values = [];
|
|
199
|
+
const errors = [];
|
|
200
|
+
for (const e of es) {
|
|
201
|
+
if (isValue(e))
|
|
202
|
+
values.push(e.value);
|
|
203
|
+
else
|
|
204
|
+
errors.push(...e.errors);
|
|
205
|
+
}
|
|
206
|
+
return errors.length > 0 ? { errors } : { value: values };
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=error.monad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.monad.js","sourceRoot":"","sources":["../../src/error.monad.ts"],"names":[],"mappings":";;;AAmCA,wDAOC;AAqBD,0BAEC;AAOD,4BAIC;AAQD,oCAGC;AAyBD,4DAUC;AAQD,sCAMC;AAQD,gDAMC;AAUD,kCAMC;AAUD,0CAMC;AAUD,oCAKC;AAUD,4CAOC;AASD,0BAMC;AAuBD,wDAUC;AA7OM,MAAM,KAAK,GAAG,CAAI,CAAI,EAAe,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAC;AAA/C,QAAA,KAAK,SAA0C;AACrD,MAAM,MAAM,GAAG,CAAC,GAAG,EAAY,EAAmB,EAAE,CAAC,CAAC,EAAC,MAAM,EAAE,EAAE,EAAC,CAAC,CAAC;AAA9D,QAAA,MAAM,UAAwD;AAE3E;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAClC,OAAe,EACf,GAAY,EACZ,MAAY;IAEZ,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,EAAC,MAAM,EAAE,CAAC,GAAG,OAAO,UAAU,OAAO,EAAE,CAAC,EAAE,MAAM,EAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAKnB;IAAyB;IAJ5C;;;OAGG;IACH,YAAmB,MAAgB,EAAS,SAAkB;QAC1D,KAAK,CAAC,M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_monad_1 = require("./error.monad");
|
|
5
|
+
// adjust path as needed
|
|
6
|
+
// Helpers for constructing test data
|
|
7
|
+
const createValue = (value) => ({ value });
|
|
8
|
+
const createErrors = (errors, reference, extras) => ({
|
|
9
|
+
errors,
|
|
10
|
+
reference,
|
|
11
|
+
extras,
|
|
12
|
+
});
|
|
13
|
+
describe("error.monad.ts ", () => {
|
|
14
|
+
describe("makeErrorFromException", () => {
|
|
15
|
+
it("wraps an Error instance and preserves extras", () => {
|
|
16
|
+
const err = new Error("boom!");
|
|
17
|
+
const extras = { code: 123 };
|
|
18
|
+
const result = (0, error_monad_1.makeErrorFromException)("CTX", err, extras);
|
|
19
|
+
expect(result.errors).toEqual(["CTX error boom!"]);
|
|
20
|
+
expect(result.extras).toBe(extras);
|
|
21
|
+
expect(result.reference).toBeUndefined();
|
|
22
|
+
});
|
|
23
|
+
it("wraps a non-Error value and omits extras when none passed", () => {
|
|
24
|
+
const result = (0, error_monad_1.makeErrorFromException)("CTX2", 42);
|
|
25
|
+
expect(result.errors).toEqual(["CTX2 error 42"]);
|
|
26
|
+
expect(result.extras).toBeUndefined();
|
|
27
|
+
expect(result.reference).toBeUndefined();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe("isValue / isErrors", () => {
|
|
31
|
+
it("identifies Value<T>", () => {
|
|
32
|
+
const v = createValue("foo");
|
|
33
|
+
expect((0, error_monad_1.isValue)(v)).toBe(true);
|
|
34
|
+
expect((0, error_monad_1.isErrors)(v)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
it("identifies Errors", () => {
|
|
37
|
+
const e = createErrors(["err"]);
|
|
38
|
+
expect((0, error_monad_1.isValue)(e)).toBe(false);
|
|
39
|
+
expect((0, error_monad_1.isErrors)(e)).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe("valueOrThrow", () => {
|
|
43
|
+
it("returns the wrapped value when given Value<T>", () => {
|
|
44
|
+
expect((0, error_monad_1.valueOrThrow)(createValue(123))).toBe(123);
|
|
45
|
+
});
|
|
46
|
+
it("throws ErrorsException when given Errors", () => {
|
|
47
|
+
const e = createErrors(["bad", "worse"], "REF");
|
|
48
|
+
expect(() => (0, error_monad_1.valueOrThrow)(e)).toThrow(error_monad_1.ErrorsException);
|
|
49
|
+
expect(() => (0, error_monad_1.valueOrThrow)(e)).toThrow("bad, worse");
|
|
50
|
+
});
|
|
51
|
+
it('throws ErrorsException when given Errors with extras', () => {
|
|
52
|
+
const e = createErrors(["bad", "worse"], "REF", { info: true });
|
|
53
|
+
expect(() => (0, error_monad_1.valueOrThrow)(e)).toThrow(error_monad_1.ErrorsException);
|
|
54
|
+
expect(() => (0, error_monad_1.valueOrThrow)(e)).toThrow("bad, worse");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe("errorsOrThrow", () => {
|
|
58
|
+
it("returns errors array when given Errors", () => {
|
|
59
|
+
const e = createErrors(["fail"]);
|
|
60
|
+
expect((0, error_monad_1.errorsOrThrow)(e)).toEqual(["fail"]);
|
|
61
|
+
});
|
|
62
|
+
it("throws ErrorsException when given Value<T>", () => {
|
|
63
|
+
const v = createValue(7);
|
|
64
|
+
expect(() => (0, error_monad_1.errorsOrThrow)(v)).toThrow(error_monad_1.ErrorsException);
|
|
65
|
+
expect(() => (0, error_monad_1.errorsOrThrow)(v)).toThrow('Expected errors but got value {"value":7}');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("errorObjectOrThrow", () => {
|
|
69
|
+
it("returns the Errors object when given Errors", () => {
|
|
70
|
+
const e = createErrors(["oops"], "XYZ");
|
|
71
|
+
expect((0, error_monad_1.errorObjectOrThrow)(e)).toBe(e);
|
|
72
|
+
});
|
|
73
|
+
it("throws ErrorsException when given Value<T>", () => {
|
|
74
|
+
const v = createValue("nope");
|
|
75
|
+
expect(() => (0, error_monad_1.errorObjectOrThrow)(v)).toThrow(error_monad_1.ErrorsException);
|
|
76
|
+
expect(() => (0, error_monad_1.errorObjectOrThrow)(v)).toThrow('Expected errors but got value {"value":"nope"}');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe("valueOrDefault", () => {
|
|
80
|
+
it("returns default when given Errors", () => {
|
|
81
|
+
const def = 999;
|
|
82
|
+
expect((0, error_monad_1.valueOrDefault)(createErrors(["err"]), def)).toBe(def);
|
|
83
|
+
});
|
|
84
|
+
it("returns default when Value holds null", () => {
|
|
85
|
+
expect((0, error_monad_1.valueOrDefault)(createValue(null), "dflt")).toBe("dflt");
|
|
86
|
+
});
|
|
87
|
+
it("returns default when Value holds undefined", () => {
|
|
88
|
+
expect((0, error_monad_1.valueOrDefault)(createValue(undefined), 5)).toBe(5);
|
|
89
|
+
});
|
|
90
|
+
it("returns actual value when present and non-nullish", () => {
|
|
91
|
+
expect((0, error_monad_1.valueOrDefault)(createValue("here"), "d")).toBe("here");
|
|
92
|
+
expect((0, error_monad_1.valueOrDefault)(createValue(0), 100)).toBe(0);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe("partitionNameAndErrorsOr", () => {
|
|
96
|
+
it("splits a NameAnd<ErrorsOr> into values and flattened errors", () => {
|
|
97
|
+
const input = {
|
|
98
|
+
a: createValue(1),
|
|
99
|
+
b: createErrors(["bad"]),
|
|
100
|
+
c: createValue(2),
|
|
101
|
+
d: createErrors(["worse"], undefined, { info: true }),
|
|
102
|
+
};
|
|
103
|
+
const { values, errors } = (0, error_monad_1.partitionNameAndErrorsOr)(input);
|
|
104
|
+
expect(values).toEqual({ a: 1, c: 2 });
|
|
105
|
+
// b and d both contribute their error strings
|
|
106
|
+
expect(errors).toEqual(["bad", "worse"]);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe("mapErrorsOr", () => {
|
|
110
|
+
it("applies f to the value when Value<T>", () => {
|
|
111
|
+
const v = createValue(4);
|
|
112
|
+
expect((0, error_monad_1.mapErrorsOr)(v, (x) => x * 3)).toEqual({ value: 12 });
|
|
113
|
+
});
|
|
114
|
+
it("preserves the same Errors object when given Errors", () => {
|
|
115
|
+
const e = createErrors(["err"]);
|
|
116
|
+
expect((0, error_monad_1.mapErrorsOr)(e, (x) => 0)).toBe(e);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe("flatMapErrorsOr", () => {
|
|
120
|
+
it("flat maps to a new Value when f returns Value", () => {
|
|
121
|
+
const v = createValue(10);
|
|
122
|
+
const out = (0, error_monad_1.flatMapErrorsOr)(v, (x) => x > 5 ? createValue("ok") : createErrors(["too small"]));
|
|
123
|
+
expect(out).toEqual({ value: "ok" });
|
|
124
|
+
});
|
|
125
|
+
it("flat maps to Errors when f returns Errors", () => {
|
|
126
|
+
const v = createValue(2);
|
|
127
|
+
const out = (0, error_monad_1.flatMapErrorsOr)(v, (x) => x > 5 ? createValue("ok") : createErrors(["too small"]));
|
|
128
|
+
expect(out).toEqual(createErrors(["too small"]));
|
|
129
|
+
});
|
|
130
|
+
it("preserves Errors unchanged", () => {
|
|
131
|
+
const e = createErrors(["fail"]);
|
|
132
|
+
const out = (0, error_monad_1.flatMapErrorsOr)(e, () => createValue("nope"));
|
|
133
|
+
expect(out).toBe(e);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe("mapErrorsOrK (async)", () => {
|
|
137
|
+
it("transforms Value asynchronously", async () => {
|
|
138
|
+
const v = createValue(20);
|
|
139
|
+
const out = await (0, error_monad_1.mapErrorsOrK)(v, async (x) => x + 2);
|
|
140
|
+
expect(out).toEqual({ value: 22 });
|
|
141
|
+
});
|
|
142
|
+
it("preserves Errors without awaiting f", async () => {
|
|
143
|
+
const e = createErrors(["async bad"]);
|
|
144
|
+
const spy = jest.fn().mockResolvedValue(99);
|
|
145
|
+
const out = await (0, error_monad_1.mapErrorsOrK)(e, spy);
|
|
146
|
+
expect(out).toBe(e);
|
|
147
|
+
expect(spy).not.toHaveBeenCalled();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
describe("flatMapErrorsOrK (async)", () => {
|
|
151
|
+
it("flat maps Value asynchronously to Value", async () => {
|
|
152
|
+
const v = createValue(7);
|
|
153
|
+
const out = await (0, error_monad_1.flatMapErrorsOrK)(v, async (x) => x > 5 ? createValue("yay") : createErrors(["nope"]));
|
|
154
|
+
expect(out).toEqual({ value: "yay" });
|
|
155
|
+
});
|
|
156
|
+
it("flat maps Value asynchronously to Errors", async () => {
|
|
157
|
+
const v = createValue(3);
|
|
158
|
+
const out = await (0, error_monad_1.flatMapErrorsOrK)(v, async (x) => x > 5 ? createValue("yay") : createErrors(["nope"]));
|
|
159
|
+
expect(out).toEqual(createErrors(["nope"]));
|
|
160
|
+
});
|
|
161
|
+
it("preserves Errors without calling f", async () => {
|
|
162
|
+
const e = createErrors(["async fail"]);
|
|
163
|
+
const spy = jest.fn().mockResolvedValue(createErrors(["won't run"]));
|
|
164
|
+
const out = await (0, error_monad_1.flatMapErrorsOrK)(e, spy);
|
|
165
|
+
expect(out).toBe(e);
|
|
166
|
+
expect(spy).not.toHaveBeenCalled();
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe("recover", () => {
|
|
170
|
+
it("returns the value when given Value<T>", () => {
|
|
171
|
+
expect((0, error_monad_1.recover)(createValue("keep"), () => "lost")).toBe("keep");
|
|
172
|
+
});
|
|
173
|
+
it("applies fallback when given Errors", () => {
|
|
174
|
+
const e = createErrors(["oops"]);
|
|
175
|
+
expect((0, error_monad_1.recover)(e, (err) => `recovered: ${err.errors.join(";")}`)).toBe("recovered: oops");
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=error.monad.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.monad.spec.js","sourceRoot":"","sources":["../../src/error.monad.spec.ts"],"names":[],"mappings":";AAAA,4BAA4B;;AAG5B,+CAUuB;AACvB,wBAAwB;AAExB,qCAAqC;AACrC,MAAM,WAAW,GAAG,CAAI,KAAQ,EAAY,EAAE,CAAC,CAAC,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YACF,MAAM,GAAG,GAAG,MAAM,IAAA,8BAAgB,EAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAC3C,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACvC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACrB,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC7C,MAAM,CAAC,IAAA,qBAAO,EAAC,WAAW,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC1C,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,IAAA,qBAAO,EAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAClE,iBAAiB,CACpB,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.report.js","sourceRoot":"","sources":["../../src/error.report.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/errors",
|
|
3
3
|
"description": "How errors are represented",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"browserslist": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cobol-ts/records": "0.0.
|
|
20
|
+
"@cobol-ts/records": "0.0.5"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"typescript": "^5.2.2",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"dist/index.js",
|
|
48
48
|
"dist/index.d.ts",
|
|
49
49
|
"dist/src/",
|
|
50
|
-
"build/"
|
|
50
|
+
"build/",
|
|
51
|
+
"dist/**/*"
|
|
51
52
|
],
|
|
52
53
|
"keywords": [
|
|
53
54
|
"indexing"
|