OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library authorization_exception; |
| 6 |
| 7 import 'dart:io'; |
| 8 |
| 9 /// An exception raised when OAuth2 authorization fails. |
| 10 class AuthorizationException implements Exception { |
| 11 /// The name of the error. Possible names are enumerated in [the spec][]. |
| 12 /// |
| 13 /// [the spec]: http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-5.2 |
| 14 final String error; |
| 15 |
| 16 /// The description of the error, provided by the server. Defaults to null. |
| 17 final String description; |
| 18 |
| 19 /// A URI for a page that describes the error in more detail, provided by the |
| 20 /// server. Defaults to null. |
| 21 final Uri uri; |
| 22 |
| 23 /// Creates an AuthorizationException. |
| 24 AuthorizationException(this.error, this.description, this.uri); |
| 25 |
| 26 /// Provides a string description of the AuthorizationException. |
| 27 String toString() { |
| 28 var header = 'OAuth authorization error ($error)'; |
| 29 if (description != null) { |
| 30 header = '$header: $description'; |
| 31 } else if (uri != null) { |
| 32 header = '$header: $uri'; |
| 33 } |
| 34 return '$header.'; |
| 35 } |
| 36 } |
OLD | NEW |