Index: pkg/oauth2/lib/src/authorization_exception.dart |
diff --git a/pkg/oauth2/lib/src/authorization_exception.dart b/pkg/oauth2/lib/src/authorization_exception.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ac3d8d569ec2ae2052be38e0c5783a934dabd5ff |
--- /dev/null |
+++ b/pkg/oauth2/lib/src/authorization_exception.dart |
@@ -0,0 +1,36 @@ |
+// Copyright (c) 2012, 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. |
+ |
+library authorization_exception; |
+ |
+import 'dart:io'; |
+ |
+/// An exception raised when OAuth2 authorization fails. |
+class AuthorizationException { |
Bob Nystrom
2012/11/16 19:53:30
extends Exception
Or implements?
nweiz
2012/11/17 01:06:27
Done.
|
+ /// The name of the error. Possible names are enumerated in [the spec][]. |
+ /// |
+ /// [the spec]: http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-5.2 |
+ final String error; |
+ |
+ /// The description of the error, provided by the server. This is optional. |
Bob Nystrom
2012/11/16 19:53:30
Will it be `null` or `""` if not provided?
nweiz
2012/11/17 01:06:27
null. Made this clear in the docs.
|
+ final String description; |
+ |
+ /// A URI for a page that describes the error in more detail, provided by the |
+ /// server. This is optional. |
+ final Uri uri; |
+ |
+ /// Creates an AuthorizationException. |
+ AuthorizationException(this.error, this.description, this.uri); |
+ |
+ /// Provides a string description of the AuthorizationException. |
+ String toString() { |
+ var header = 'OAuth authorization error ($error)'; |
+ if (description != null) { |
+ header = '$header: $description'; |
+ } else if (uri != null) { |
+ header = '$header: $uri'; |
+ } |
+ return '$header.'; |
Bob Nystrom
2012/11/16 19:53:30
I think I'd prefer to rely on the description havi
nweiz
2012/11/17 01:06:27
I haven't actually seen any OAuth2 providers that
|
+ } |
+} |