mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-12 09:45:32 +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 }) {
|
||||
const config = getConfig(commonArgs);
|
||||
const { imports = [] } = commonArgs;
|
||||
return Aqua.compile(new Input(code), imports, config);
|
||||
async function compile(...args) {
|
||||
try {
|
||||
const res = await Aqua.compile(...args);
|
||||
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 }) {
|
||||
const config = getConfig(commonArgs);
|
||||
const { imports = [] } = commonArgs;
|
||||
return Aqua.compile(new Path(filePath), imports, config);
|
||||
export function compileFromString({ code, imports = [], ...commonArgs }) {
|
||||
return compile(new Input(code), imports, getConfig(commonArgs));
|
||||
}
|
||||
|
||||
export function compileFromPath({ filePath, imports = [], ...commonArgs }) {
|
||||
return compile(new Path(filePath), imports, getConfig(commonArgs));
|
||||
}
|
||||
|
||||
export function compileAquaCallFromString({
|
||||
code,
|
||||
funcCall,
|
||||
data,
|
||||
imports = [],
|
||||
...commonArgs
|
||||
}) {
|
||||
const config = getConfig(commonArgs);
|
||||
const { imports = [] } = commonArgs;
|
||||
return Aqua.compile(
|
||||
return compile(
|
||||
new Call(funcCall, data, new Input(code)),
|
||||
imports,
|
||||
config,
|
||||
getConfig(commonArgs),
|
||||
);
|
||||
}
|
||||
|
||||
@ -53,13 +65,12 @@ export function compileAquaCallFromPath({
|
||||
filePath,
|
||||
funcCall,
|
||||
data,
|
||||
imports = [],
|
||||
...commonArgs
|
||||
}) {
|
||||
const config = getConfig(commonArgs);
|
||||
const { imports = [] } = commonArgs;
|
||||
return Aqua.compile(
|
||||
return compile(
|
||||
new Call(funcCall, data, new Input(filePath)),
|
||||
imports,
|
||||
config,
|
||||
getConfig(commonArgs),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user