Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

'Undefined function' when calling functions which throw exceptions #971

Closed
olostan opened this issue Apr 28, 2014 · 5 comments
Closed

'Undefined function' when calling functions which throw exceptions #971

olostan opened this issue Apr 28, 2014 · 5 comments

Comments

@olostan
Copy link

olostan commented Apr 28, 2014

If in any code that is invoked by AngularDart invoked a code that raise NoSuchMethod then AngularDart shows Undefined function exception, however function is defined.

Steps to reproduce:

  1. Take "hello_world" example.
  2. Into HelloWorld controller add method:
  Test() {
    String x = null;
    if (x.length==0)
      name = "Tested";
  }
  1. Into html view add
    <button ng-click="ctrl.Test()">Test</button>
  2. Run application in Dartium and press "Test" button.

You'll see Undefined function Test. However Test is defined in controller.

It can confuse users, as even if there is mistake somewhere inside of the call. It took me some time to understand what is the problem.

@vicb
Copy link
Contributor

vicb commented Apr 28, 2014

The solution should be as simple as changing

      } else {
        try {
          return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
        } on NoSuchMethodError catch (e) {
          throw 'Undefined function $name';
        }
      }

to

      } else {
        return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
      }

in parser_dynamic.dart.

Needs a test to PR.

@mhevery mhevery self-assigned this Apr 30, 2014
@kemallette
Copy link
Contributor

I've also just run in to this issue in one of my components. Definitely caused some hair pulling!

As always though, thanks sincerely to all contributors for the outstanding work happening. New framework hiccups aside, it's been a joy working with Angular and Dart and watching all the progress being made. :)

@jbdeboer
Copy link
Contributor

@kemallette What version of AngularDart are you using? This may have been fixed by @chirayuk in the github version.

@jbdeboer jbdeboer changed the title 'Undefined function' when calling functions of null 'Undefined function' when calling functions which throw exceptions May 15, 2014
@jbdeboer jbdeboer assigned mvuksano and unassigned mhevery May 15, 2014
@jbdeboer
Copy link
Contributor

@markovuksanovic Could you put together a PR for this issue? @vicb's approach looks correct.

@kemallette
Copy link
Contributor

@jbdeboer version: 0.11.0

mvuksano added a commit to mvuksano/angular.dart that referenced this issue May 24, 2014
mvuksano added a commit to mvuksano/angular.dart that referenced this issue May 25, 2014
mvuksano added a commit to mvuksano/angular.dart that referenced this issue May 25, 2014
mvuksano added a commit to mvuksano/angular.dart that referenced this issue May 25, 2014
mvuksano added a commit to mvuksano/angular.dart that referenced this issue May 25, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

6 participants