-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Investigate function parameter validation for public Engine API #2529
Comments
It could make use of prototype extending: All the required code could be autogenerated from the var original = pc.Entity.prototype.addChild;
pc.Entity.prototype.addChild = function(node) {
if (!node) {
console.trace("node is undefined");
return;
}
original.call(this, node);
} Otherwise I only see AST rewriting as an option (during DEBUG) with a parsed |
Common issue I found, is when error trace shows But it is important that it does not alter the behaviour of function, such as: func(arg) {
// #ifdef DEBUG
if (arg === null) {
console.warn('arg should not be a null');
return; // - not good
}
// #endif
return arg;
} Here it will return |
some developers use integrations that grab errors reporting by the engine to console, to be able to keep an eye on their product behavior in the wild. For these developers it would probably be better to have critical errors reported at all times? @yak32 - would you know more about this? Perhaps we need #ERRORS and have build with a without it? |
What stops them to use DEBUG build in such case? |
Well performance - occasionally we run slower code in #DEBUG - like _checkFbo for example, but few others. |
To help engine customers catch issues early instead of getting unhandled exceptions / undefined behavior, we should consider validating parameters passed into public API functions / possibly some internal functions.
Validation:
And likely some other validations - please add comments with ideas and suggestions on how this could be implemented.
The text was updated successfully, but these errors were encountered: