Add Error and Result types
This commit is contained in:
parent
85acefbb6d
commit
52f73b4836
|
@ -1,5 +1,7 @@
|
||||||
|
extern crate hyper;
|
||||||
extern crate inth_oauth2;
|
extern crate inth_oauth2;
|
||||||
|
|
||||||
|
use std::io;
|
||||||
use inth_oauth2::Client;
|
use inth_oauth2::Client;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -15,4 +17,9 @@ fn main() {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
println!("{}", auth_uri);
|
println!("{}", auth_uri);
|
||||||
|
|
||||||
|
let mut code = String::new();
|
||||||
|
io::stdin().read_line(&mut code).unwrap();
|
||||||
|
|
||||||
|
client.request_access_token(hyper::Client::new(), &code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
use std::result;
|
||||||
|
|
||||||
|
use url;
|
||||||
|
use hyper;
|
||||||
|
|
||||||
|
/// Errors that can occur during authentication flow.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Error {
|
||||||
|
Url(url::ParseError),
|
||||||
|
Hyper(hyper::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Result type returned from authentication flow methods.
|
||||||
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
|
impl From<url::ParseError> for Error {
|
||||||
|
fn from(err: url::ParseError) -> Error {
|
||||||
|
Error::Url(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<hyper::Error> for Error {
|
||||||
|
fn from(err: hyper::Error) -> Error {
|
||||||
|
Error::Hyper(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,3 +7,6 @@ mod client;
|
||||||
|
|
||||||
pub use token::Token;
|
pub use token::Token;
|
||||||
mod token;
|
mod token;
|
||||||
|
|
||||||
|
pub use error::{Error, Result};
|
||||||
|
mod error;
|
||||||
|
|
Loading…
Reference in New Issue