 			task.resume()
 			semaphore.wait()
 		}
-		NSLog("Exit due to error: \(encounterError!)")
-		exit(2)
+		throw encounterError!
 	}
 
 }

						}
					}
					for update in updates {
						handler(.success(update), self)
					}
				case .failure(let error):
					handler(.failure(error), self)
					encounterError = error
				}
				semaphore.signal()

		self.urlPrefix = "https://api.telegram.org/bot"+token+"/"
	}

	public func run(withHandler handler: @escaping UpdateHandler) throws {
		var offset = 0
		let semaphore = DispatchSemaphore(value: 0)
		var encounterError: Swift.Error?
		while encounterError == nil {
			let task = session.dataTask(with: URL(string: urlPrefix + "getupdates?timeout=60&offset=\(offset)")!) { data, _, error in
				guard let data = data else {
					encounterError = error!
					semaphore.signal()
					return
