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