praekelt / go-jsbox-location

Location finder for go-jsbox
Other
2 stars 0 forks source link

Error checking for objects #8

Closed rudigiesler closed 10 years ago

rudigiesler commented 10 years ago

Need to add error checking for if an object that is specified in the parameters does not exist in the object received from gmaps.

rudigiesler commented 10 years ago

@justinvdm What should I use for throwing the error? I see that there are a few different types of errors in the jsbox API.

justinvdm commented 10 years ago

I think it would be fine to just throw a normal Error. If you like, you could extend vumigo.utils.BaseError with your own error type if you like (something like var JsboxLocationError = BaseError.extend(function(self) { ... });), but I think a normal Error should be fine.

rudigiesler commented 10 years ago

@justinvdm How would I then catch the error during testing?

justinvdm commented 10 years ago

Good question. You could do something like:

  return tester
      ...
      .run()
      .catch(function(e) {
          assert(e instanceof Error);
          assert.equal(e.message, ':(');
      });
rudigiesler commented 10 years ago

Thanks :cake: . Sent a pull request: https://github.com/praekelt/go-jsbox-location/pull/8

justinvdm commented 10 years ago

Minor comment, otherwise looks good.

justinvdm commented 10 years ago

:+1: