Skip to content

Commit

Permalink
Replace print() + abort() with fatalError() so Quick Testing Framewor…
Browse files Browse the repository at this point in the history
…k correctly handles error
  • Loading branch information
James Thimont committed Aug 2, 2016
1 parent 855bef6 commit dca7777
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 dca7777

Please sign in to comment.