Skip to content

Callback needs error as 1st param #4

@drauschenbach

Description

@drauschenbach

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);
  })
;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions