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

Callback needs error as 1st param #4

Open
drauschenbach opened this issue Nov 6, 2011 · 1 comment
Open

Callback needs error as 1st param #4

drauschenbach opened this issue Nov 6, 2011 · 1 comment

Comments

@drauschenbach
Copy link

To make this module compatible with other fluent modules such as "seq", the first argument of the callback needs to be the error status. And this would be used instead of throwing an Error.

My current code:

Seq()
  .seq(function() {
    // Geocode request
    var _this=this;
    try {
      Geo.geocoder(Geo.google, vevent.location, sensor, function(formattedAddress, latitude, longitude, details) {
        console.log('geocode results', formattedAddress, latitude, longitude, details);
        _this(null);
      });
    } catch (error) {
      console.log('Geocode failed', error);
      _this(error);
    }
  })
;

Should become:

Seq()
  // make geocode request
  .seq(function() {
    Geo.geocoder(Geo.google, vevent.location, sensor, this);
  })
  // process geocode response
  .seq(function(formattedAddress, latitude, longitude, details) {
    console.log('geocode results', formattedAddress, latitude, longitude, details);
  })
  // process geocode failure
  .catch(function(error) {
    console.log('Geocode failed', error);
  })
;
@tlhunter
Copy link

tlhunter commented Jan 1, 2013

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants