Hello,
Could I create a Server Connect extension/module like the Try/Catch? I’ve checked the Try/Catch code but I don’t know how to make the hjson.
I see some pretty funny possibilities with modules that allow steps inside. Like building a Cache block or throwing everything into a Queue for later processing.
Now, a question for the Wappler team: Method trycatch is executed, with the argument “options” being an object containing “try” and “catch” (see picture on right)
Line 180, trycatch calls exec with argument options.try, which is an object containing “steps” (see picture on right)
Line 193, there’s an if (options.exec […]), but argument (options) only has “steps”! There’s no “exec”! It would always fail, what am I missing?
// core.js
trycatch: async function(options) {
try {
await this.exec(options.try, true);
} catch (error) {
this.scope.set('$_ERROR', error.message || error);
this.error = false;
if (options.catch) {
await this.exec(options.catch, true);
}
}
},
exec: async function(options) {
var data = {};
if (options.exec && fs.existsSync(`app/modules/lib/${options.exec}.json`)) {
let parentData = this.data;
this.data = {};
this.scope = this.scope.create({ $_PARAM: this.parse(options.params) });
await this.exec(await fs.readJSON(`app/modules/lib/${options.exec}.json`), true);
data = this.data;
this.scope = this.scope.parent;
this.data = parentData;
} else {
throw new Error(`There is no action called '${options.exec}' found in the library.`);
}
return data;
},
Community Page
Last updated:
Last updated: