-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled errors using sclang.interpret on Electron #76
Comments
Sorry my fault, there was something wrong in my development configuration. |
I love errors that close themselves :) |
@crucialfelix actually I was wrong, the problem is still there lang.interpret(args.message).then(
function(result) {
// result is a native javascript array
console.log("= " + result);
return result;
},
function(error) {
// syntax or runtime errors
// are returned as javascript objects
console.log('error', error);
},
); The code is contained in an electron handle callback that should pass both results and errors to the renderer process. Sadly errors don't get handled. // ... electron stuff
const sc = require("supercolliderjs");
async function bootSuperCollider() {
const lang = await sc.lang.boot({ echo: false, debug: false });
ipcMain.handle("interpret_sclang", async (_, args) => {
const output = await lang.interpret(args.message).then(
function(result) {
// result is a native javascript array
console.log("= " + result);
return result;
},
function(error) {
// syntax or runtime errors
// are returned as javascript objects
console.log('error', error);
return error;
},
);
console.log({ output });
return output;
});
}
bootSuperCollider(); |
Note that you are using both const output = await lang.interpret(args.message).then( so output will be either result OR error. I guess it would work though. You could also try writing it differently: async (_, args) => {
try {
const result = await lang.interpret(args.message);
return {result};
} catch(error) {
log.error(error);
return {error};
}
} just to see if it reveals some other information about the problem. |
The error object should be
https://crucialfelix.github.io/supercolliderjs/#/packages/lang/SCLang?id=interpret https://crucialfelix.github.io/supercolliderjs/#/packages/supercolliderjs/SCLangError I can see from your stack trace that you are using the previous release (before the typescript port) but the code is the same:
So if stdout was empty then it isn't an object. I should check that it did result in an object. Could you post what the .message (code input) is? |
The input was |
const sc = require("supercolliderjs");
sc.lang.boot().then(async function(lang) {
const ciao = await lang.interpret("ciao");
console.log(ciao);
await lang.quit();
});
bug confirmed! |
const sc = require("supercolliderjs");
sc.lang.boot().then(async function(lang) {
try {
const ciao = await lang.interpret("ciao");
console.log(ciao);
} catch (error) {
console.error(error);
}
await lang.quit();
});
fix coming... |
1.0.1 is released. |
Thank you! is it on npm already ? |
Cannot catch errors raised in the interpreter.
The console outputs this error
The text was updated successfully, but these errors were encountered: