mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-12 17:55:33 +00:00
feat: rethrow errors to capture stacktrace (#907)
* feat: rethrow errors to capture stacktrace * add null check
This commit is contained in:
parent
8741c910be
commit
66638afa2d
@ -22,30 +22,42 @@ function getConfig({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compileFromString({ code, ...commonArgs }) {
|
async function compile(...args) {
|
||||||
const config = getConfig(commonArgs);
|
try {
|
||||||
const { imports = [] } = commonArgs;
|
const res = await Aqua.compile(...args);
|
||||||
return Aqua.compile(new Input(code), imports, config);
|
return res;
|
||||||
|
} catch (error) {
|
||||||
|
if (
|
||||||
|
typeof error === "object" &&
|
||||||
|
error !== null &&
|
||||||
|
"message" in error &&
|
||||||
|
typeof error.message === "string"
|
||||||
|
) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compileFromPath({ filePath, ...commonArgs }) {
|
export function compileFromString({ code, imports = [], ...commonArgs }) {
|
||||||
const config = getConfig(commonArgs);
|
return compile(new Input(code), imports, getConfig(commonArgs));
|
||||||
const { imports = [] } = commonArgs;
|
}
|
||||||
return Aqua.compile(new Path(filePath), imports, config);
|
|
||||||
|
export function compileFromPath({ filePath, imports = [], ...commonArgs }) {
|
||||||
|
return compile(new Path(filePath), imports, getConfig(commonArgs));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compileAquaCallFromString({
|
export function compileAquaCallFromString({
|
||||||
code,
|
code,
|
||||||
funcCall,
|
funcCall,
|
||||||
data,
|
data,
|
||||||
|
imports = [],
|
||||||
...commonArgs
|
...commonArgs
|
||||||
}) {
|
}) {
|
||||||
const config = getConfig(commonArgs);
|
return compile(
|
||||||
const { imports = [] } = commonArgs;
|
|
||||||
return Aqua.compile(
|
|
||||||
new Call(funcCall, data, new Input(code)),
|
new Call(funcCall, data, new Input(code)),
|
||||||
imports,
|
imports,
|
||||||
config,
|
getConfig(commonArgs),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,13 +65,12 @@ export function compileAquaCallFromPath({
|
|||||||
filePath,
|
filePath,
|
||||||
funcCall,
|
funcCall,
|
||||||
data,
|
data,
|
||||||
|
imports = [],
|
||||||
...commonArgs
|
...commonArgs
|
||||||
}) {
|
}) {
|
||||||
const config = getConfig(commonArgs);
|
return compile(
|
||||||
const { imports = [] } = commonArgs;
|
|
||||||
return Aqua.compile(
|
|
||||||
new Call(funcCall, data, new Input(filePath)),
|
new Call(funcCall, data, new Input(filePath)),
|
||||||
imports,
|
imports,
|
||||||
config,
|
getConfig(commonArgs),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user