pjs.transferControl()
Description
This API transfers control to another Profound.js module. This is similar to calling a module, except that the caller is removed from the call stack before the call is made. Therefore, when the called program exits, control is not returned to the caller. Instead, the previous call stack entry takes over.
Parameters
Module name (String) - The Profound.js module to transfer control to.
Parameters (optional) - One or more parameters.
Exception Handling
Profound.js transfers control by throwing a special exception that is monitored by the Profound.js framework. If you are using a custom try/catch block around the pjs.transferControl() API call, you should re-throw the exception.
Example
Using try/catch With pjs.transferControl()
// pjs.transferControl() hands the job over to another module and removes the
// current module from the call stack, so nothing after it runs. It signals the
// framework by throwing a TransferControlException -- if you wrap the call in
// your own try/catch, you must let that exception through.
try {
// Your own logic, which could fail before the hand-off happens.
const settings = pjs.require("config/settings.js");
// Control passes to "myprogram"; execution never returns to this line.
pjs.transferControl("myprogram", settings.startupParm);
}
catch (error) {
// Re-throw the framework's transfer signal so the hand-off can complete.
if (error instanceof pjs.TransferControlException) throw error;
// Anything else is a genuine error raised by the code above.
else doSomethingElse(error);
}