Comparing version 97.0.0 to 98.0.0
@@ -7,9 +7,18 @@ import { reverse } from "./array.js"; | ||
const pipeWithoutStack = (...fs) => ((...x) => reduce((v, f) => f(v), () => fs[0](...x))(fs.slice(1))); | ||
const augmentException = (codeLocation) => (e) => { | ||
e.message = (e.message ? (e.message + "\n") : "") + codeLocation; | ||
return e; | ||
// deno-lint-ignore no-explicit-any | ||
const augmentAndRethrowException = (location) => (e) => { | ||
if (e === undefined) { | ||
console.error(`undefined error within ${location}`); | ||
throw e; | ||
} | ||
try { | ||
e.message = (e.message ? (e.message + "\n") : "") + location; | ||
} | ||
catch (augmentError) { | ||
console.error(`error within ${location}, gamla could not augment error stack`, augmentError, e); | ||
} | ||
throw e; | ||
}; | ||
export const errorBoundry = (f) => { | ||
const location = currentLocation(4); | ||
const augment = augmentException(location); | ||
return ((...x) => { | ||
@@ -19,17 +28,7 @@ try { | ||
return (isPromise(result)) | ||
? result.catch((e) => { | ||
if (e === undefined) { | ||
console.error(`undefined error within ${location}`); | ||
throw e; | ||
} | ||
throw augment(e); | ||
}) | ||
? result.catch(augmentAndRethrowException(location)) | ||
: result; | ||
} | ||
catch (e) { | ||
if (e === undefined) { | ||
console.error(`undefined error within ${location}`); | ||
throw e; | ||
} | ||
throw augment(e); | ||
augmentAndRethrowException(location)(e); | ||
} | ||
@@ -36,0 +35,0 @@ }); |
{ | ||
"name": "gamla", | ||
"version": "97.0.0", | ||
"version": "98.0.0", | ||
"description": "Functional programming with async and type safety", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -10,9 +10,18 @@ "use strict"; | ||
const pipeWithoutStack = (...fs) => ((...x) => (0, reduce_js_1.reduce)((v, f) => f(v), () => fs[0](...x))(fs.slice(1))); | ||
const augmentException = (codeLocation) => (e) => { | ||
e.message = (e.message ? (e.message + "\n") : "") + codeLocation; | ||
return e; | ||
// deno-lint-ignore no-explicit-any | ||
const augmentAndRethrowException = (location) => (e) => { | ||
if (e === undefined) { | ||
console.error(`undefined error within ${location}`); | ||
throw e; | ||
} | ||
try { | ||
e.message = (e.message ? (e.message + "\n") : "") + location; | ||
} | ||
catch (augmentError) { | ||
console.error(`error within ${location}, gamla could not augment error stack`, augmentError, e); | ||
} | ||
throw e; | ||
}; | ||
const errorBoundry = (f) => { | ||
const location = (0, trace_js_1.currentLocation)(4); | ||
const augment = augmentException(location); | ||
return ((...x) => { | ||
@@ -22,17 +31,7 @@ try { | ||
return ((0, promise_js_1.isPromise)(result)) | ||
? result.catch((e) => { | ||
if (e === undefined) { | ||
console.error(`undefined error within ${location}`); | ||
throw e; | ||
} | ||
throw augment(e); | ||
}) | ||
? result.catch(augmentAndRethrowException(location)) | ||
: result; | ||
} | ||
catch (e) { | ||
if (e === undefined) { | ||
console.error(`undefined error within ${location}`); | ||
throw e; | ||
} | ||
throw augment(e); | ||
augmentAndRethrowException(location)(e); | ||
} | ||
@@ -39,0 +38,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
352386
2586