Skip to content
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

New js utility API for decoding error #974

Open
matteo-cristino opened this issue Nov 21, 2024 · 3 comments · May be fixed by #1007
Open

New js utility API for decoding error #974

matteo-cristino opened this issue Nov 21, 2024 · 3 comments · May be fixed by #1007
Labels
bindings issue related to language bindings

Comments

@matteo-cristino
Copy link
Collaborator

Add a utility function called decode_error that parse the zencode logs and return only the real errors, i.e. the strings that starts with a [!] both in logs and in the J64 TRACE. Example of usage

import {zencode_exec, decode_error} from 'zenroom'

zencode_exec(scripts, {}).catch(decode_error);
// same as
let result
try {
    result = await zencode_exec(script, {})
} catch(
    decode_error(result)
}

In both cases the error should be printed to console.error and also returned.

Right @puria ?

@puria
Copy link
Member

puria commented Nov 21, 2024

I would keep the same behavior of zencode_exec, does that console.lo/error automatically? I don't remember, if yes then also decode_error should

@matteo-cristino
Copy link
Collaborator Author

no, it does not print anything. Then it will just return the string containing the clear error

@jaromil
Copy link
Member

jaromil commented Nov 25, 2024

I understand this belongs to the js wrapper shipped with npm. It is good to have, hoping it can be done without adding dependencies to the npm package, where we proudly have zero.

@matteo-cristino matteo-cristino linked a pull request Jan 19, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings issue related to language bindings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants