Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Unified Diff: pkg/http/lib/src/base_client.dart

Issue 216603010: Rip out dart:io from pkg/http wherever possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http/lib/http.dart ('k') | pkg/http/lib/src/byte_stream.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/base_client.dart
diff --git a/pkg/http/lib/src/base_client.dart b/pkg/http/lib/src/base_client.dart
index 87a4224ce9995867992db0eebed3a5949ee35401..da38e705000680f1a0ccab648f6dd14392034fed 100644
--- a/pkg/http/lib/src/base_client.dart
+++ b/pkg/http/lib/src/base_client.dart
@@ -6,11 +6,11 @@ library base_client;
import 'dart:async';
import 'dart:convert';
-import 'dart:io';
import 'dart:typed_data';
import 'base_request.dart';
import 'client.dart';
+import 'exception.dart';
import 'request.dart';
import 'response.dart';
import 'streamed_response.dart';
@@ -89,7 +89,7 @@ abstract class BaseClient implements Client {
/// can be a [Uri] or a [String], and returns a Future that completes to the
/// body of the response as a String.
///
- /// The Future will emit an [HttpException] if the response doesn't have a
+ /// The Future will emit a [ClientException] if the response doesn't have a
/// success status code.
///
/// For more fine-grained control over the request and response, use [send] or
@@ -105,7 +105,7 @@ abstract class BaseClient implements Client {
/// can be a [Uri] or a [String], and returns a Future that completes to the
/// body of the response as a list of bytes.
///
- /// The Future will emit an [HttpException] if the response doesn't have a
+ /// The Future will emit an [ClientException] if the response doesn't have a
/// success status code.
///
/// For more fine-grained control over the request and response, use [send] or
@@ -122,7 +122,8 @@ abstract class BaseClient implements Client {
/// Implementers should call [BaseRequest.finalize] to get the body of the
/// request as a [ByteStream]. They shouldn't make any assumptions about the
/// state of the stream; it could have data written to it asynchronously at a
- /// later point, or it could already be closed when it's returned.
+ /// later point, or it could already be closed when it's returned. Any
+ /// internal HTTP errors should be wrapped as [ClientException]s.
Future<StreamedResponse> send(BaseRequest request);
/// Sends a non-streaming [Request] and returns a non-streaming [Response].
@@ -157,7 +158,8 @@ abstract class BaseClient implements Client {
if (response.reasonPhrase != null) {
message = "$message: ${response.reasonPhrase}";
}
- throw new HttpException("$message.");
+ if (url is String) url = Uri.parse(url);
+ throw new ClientException("$message.", url);
}
/// Closes the client and cleans up any resources associated with it. It's
« no previous file with comments | « pkg/http/lib/http.dart ('k') | pkg/http/lib/src/byte_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698