Skip to content

Commit

Permalink
Merge pull request #54 from james-thimont-bcgdv/james-thimont-bcgdv/e…
Browse files Browse the repository at this point in the history
…rror-handling

Replace print() + abort() with fatalError() so Quick Testing Framework correctly handles error
  • Loading branch information
eliperkins committed Oct 27, 2016
2 parents 5673867 + dca7777 commit 62f4bb6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions DVR/SessionDataTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,23 @@ class SessionDataTask: NSURLSessionDataTask {
}

if cassette != nil {
print("[DVR] Invalid request. The request was not found in the cassette.")
abort()
fatalError("[DVR] Invalid request. The request was not found in the cassette.")
}

// Cassette is missing. Record.
if session.recordingEnabled == false {
print("[DVR] Recording is disabled.")
abort()
fatalError("[DVR] Recording is disabled.")
}

let task = session.backingSession.dataTaskWithRequest(request) { [weak self] data, response, error in

//Ensure we have a response
guard let response = response else {
print("[DVR] Failed to record because the task returned a nil response.")
abort()
fatalError("[DVR] Failed to record because the task returned a nil response.")
}

guard let this = self else {
print("[DVR] Something has gone horribly wrong.")
abort()
fatalError("[DVR] Something has gone horribly wrong.")
}

// Still call the completion block so the user can chain requests while recording.
Expand Down

0 comments on commit 62f4bb6

Please sign in to comment.