This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Javascript Promises require the use of a function named "catch". Netbeans' Javascript parser mistreats this function call as a try-catch block resulting in two problems: 1. Th wrong code-formatting rules get applied, resulting in "catch (foo)" instead of "catch(foo)". 2. The word "catch" is highlighted as a reserved word. This bug prevents me from enabling https://github.com/jscs-dev/node-jscs rule "disallowSpacesInCallExpression: true".
Well catch is a reserved keyword in JavaScript and thus function/variables cannot be named with "catch". Check [1] and [2]. function catch(){} is illegal, but myObject.catch = function(){} is legal (although in some older browsers still could cause issues) How exactly do you use it with Promises? I think it is similar to promise.then(function(){}).catch(function(){}) which works fine for me. Could you please post here your code? Thank you [1] http://www.w3schools.com/js/js_reserved.asp [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar
1. I am aware this syntax will cause problems for older browsers. I am working exclusively with modern browsers and I expect Netbeans to support them. 2. You are right that some cases of catch() works properly. Here is a specific use-case to help you reproduce the problem: This works: return Authentication.insert(email, password).catch(function(error) { // do something }); This does not: return Authentication.insert(email, password). catch (function(error) { // do something }); The only difference seems to be whether "catch" shows up on a newline. In the case case, the word "catch" is highlighted in blue (like a reserved word) and there is an undesirable space between "catch" and the braces.
Changeset: 11c2f8942d19 Author: Roman Svitanic <rsvitanic@netbeans.org> Date: 2014-12-12 16:18 Message: #248443: Wrong code format for function named catch - fixed
Integrated into 'main-silver', will be available in build *201412130001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/11c2f8942d19 User: Roman Svitanic <rsvitanic@netbeans.org> Log: #248443: Wrong code format for function named catch - fixed Task #248443 - Wrong code format for function named catch