Giter VIP home page Giter VIP logo

kiturarequest's People

Contributors

michalkalinowski- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kiturarequest's Issues

Errors handling #question

Currently Request class stores and handles only RequestError error types, but there are other error types including HTTPParserErrorType that can be thrown in process method.
Maybe there is some sense in handling them all in some way?

First solution i've come to is make both initializer and response methods (including callbacks) throwable so any error type can be handled by do ... catch and result looks like this:

do {
  try Request(method: .GET, invalidURL)
    .response { request, response, data in
      ...
    }
    ...
} catch let error as RequestError {
  XCTAssertEqual(error, RequestError.InvalidURL)
} catch {
  XCTFail()
}

Other solution i've come to is to switch RequestError with ErrorProtocol. With this test looks like this:

let testRequest = Request(method: .GET, invalidURL)
  .response { request, response, data, error in
    ... 
  }

switch testRequest.error {
  case let error as RequestError:
    XCTAssertEqual(error, RequestError.InvalidURL)
  default:
    XCTFail()
}

Doesn't build on Linux

Building on Ubuntu 15.10 with DEVELOPMENT-SNAPSHOT-2016-05-03-a produces following errors:

/home/michal/clones/KituraRequest/Sources/KituraRequest/ParameterEncoding.swift:43:45: error: incorrect argument label in call (have 'url:resolvingAgainstBaseURL:', expected 'URL:resolvingAgainstBaseURL:')
      guard let components = NSURLComponents(url: request.url!, resolvingAgainstBaseURL: false) else {
                                            ^~~~
                                             URL
/home/michal/clones/KituraRequest/Sources/KituraRequest/ParameterEncoding.swift:55:63: error: argument type '[String : AnyObject]' does not conform to expected type 'AnyObject'
      let data = try NSJSONSerialization.data(withJSONObject: parameters, options: options)
                                                              ^~~~~~~~~~
/home/michal/clones/KituraRequest/Sources/KituraRequest/Request.swift:61:21: error: value of type 'NSMutableURLRequest' has no member 'httpBody'
      if let body = urlRequest.httpBody {
                    ^~~~~~~~~~ ~~~~~~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.