RobotsAndPencils / buford

A push notification delivery engine for the new HTTP/2 APNS service.
MIT License
475 stars 52 forks source link

Return type should be Error #79

Closed vnodecg closed 8 years ago

vnodecg commented 8 years ago

in #97 return type should be Error not builtin error.

With return type Error user will have options like getting timestamp of unregistered error

nathany commented 8 years ago

Right now some errors that could occur don't conform to the Error type. Such as an error building a request https://github.com/RobotsAndPencils/buford/blob/master/push/service.go#L70 or making an HTTP request: https://github.com/RobotsAndPencils/buford/blob/master/push/service.go#L77

You can use a type assertion to get the push.Error type back: https://github.com/RobotsAndPencils/buford#error-responses

vnodecg commented 8 years ago

I was trying to access the timestamp. All I get is error

nathany commented 8 years ago

Take a look at type assertions.

if e, ok := err.(*push.Error); ok {
    log.Println(e.Timestamp)
}