balanced / balanced-api

Balanced API specification.
221 stars 72 forks source link

Errors aren't being wrapped #467

Closed steveklabnik closed 10 years ago

steveklabnik commented 10 years ago

related: https://github.com/balanced/balanced-api/issues/455

When you try to refund an unstored card, you don't get a wrapped error:

  Scenario: Crediting a deleted card leads to failure                                                                                                              
    Given I have tokenized a card                                                                                                                                  
    When I make a DELETE request to the href "href"                                                                                                                
    Then I should get a 204 status code                                                                                                                            

    When I make a POST request to /cards/:cards_id/credits                                                                                                         
    Then I should get a 404 status code                                                                                                                            

    And the response is valid according to the "errors" schema                                                                                                     
    And the fields on this error match:                                                                                                                            
    """                                                                                                                                                            
      {                                                                                                                                                            
       "category_code": "not-found"                                                                                                                                
      }                                                                                                                                                            
    """       
{"status"=>"Not Found", "category_code"=>"not-found", "category_type"=>"request", "description"=>"<p>The requested URL was not found on the server.</p><p>If you en
tered the URL manually please check your spelling and try again.</p> Your request id is OHMa4fd1810771f11e3bae9026ba7f8ec28.", "request_id"=>"OHMa4fd1810771f11e3ba
e9026ba7f8ec28", "status_code"=>404}

This should be wrapped in an error object.

mjallday commented 10 years ago

@steveklabnik are you passing revision 1.1 headers? by default everything is revision 1.0 so it won't be wrapped... if you are passing those headers please reopen and we'll investigate.

steveklabnik commented 10 years ago

Yes, I send this header with every request: https://github.com/balanced/balanced-api/pull/431/files#diff-6e23a314d333a0bdd832132c72cf1835R6

mjallday commented 10 years ago

@steveklabnik is this still happening?

curl https://api.balancedpayments.com/fourohfour -H "Accept: application/vnd.api+json;revision=1.1"

{
  "errors": [
    {
      "status": "Not Found",
      "category_code": "not-found",
      "description": "<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p> Your request id is OHM6af85fd8820c11e38fce026ba7f8ec28.",
      "status_code": 404,
      "category_type": "request",
      "request_id": "OHM6af85fd8820c11e38fce026ba7f8ec28"
    }
  ]
}
steveklabnik commented 10 years ago

Looks like we're good!