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

Unified Diff: lib/src/utils.dart

Issue 1307353003: Add an AuthenticationChallenge class. (Closed) Base URL: git@github.com:dart-lang/http_parser@master
Patch Set: Code review changes Created 5 years, 4 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 | « lib/src/scan.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4dcee1988000e1a0d77be60a35765881625bd753
--- /dev/null
+++ b/lib/src/utils.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:source_span/source_span.dart';
+
+/// Runs [body] and wraps any format exceptions it produces.
+///
+/// [name] should describe the type of thing being parsed, and [value] should be
+/// its actual value.
+wrapFormatException(String name, String value, body()) {
+ try {
+ return body();
+ } on SourceSpanFormatException catch (error) {
+ throw new SourceSpanFormatException(
+ 'Invalid $name: ${error.message}', error.span, error.source);
+ } on FormatException catch (error) {
+ throw new FormatException(
+ 'Invalid $name "$value": ${error.message}',
+ error.source,
+ error.offset);
+ }
+}
« no previous file with comments | « lib/src/scan.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698