| 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 /// An exception raised when OAuth2 authorization fails. | |
| 8 class AuthorizationException implements Exception { | |
| 9 /// The name of the error. Possible names are enumerated in [the spec][]. | |
| 10 /// | |
| 11 /// [the spec]: http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-5.2 | |
| 12 final String error; | |
| 13 | |
| 14 /// The description of the error, provided by the server. Defaults to null. | |
| 15 final String description; | |
| 16 | |
| 17 /// A URI for a page that describes the error in more detail, provided by the | |
| 18 /// server. Defaults to null. | |
| 19 final Uri uri; | |
| 20 | |
| 21 /// Creates an AuthorizationException. | |
| 22 AuthorizationException(this.error, this.description, this.uri); | |
| 23 | |
| 24 /// Provides a string description of the AuthorizationException. | |
| 25 String toString() { | |
| 26 var header = 'OAuth authorization error ($error)'; | |
| 27 if (description != null) { | |
| 28 header = '$header: $description'; | |
| 29 } else if (uri != null) { | |
| 30 header = '$header: $uri'; | |
| 31 } | |
| 32 return '$header.'; | |
| 33 } | |
| 34 } | |
| OLD | NEW |