diff options
Diffstat (limited to 'src/client.rs')
-rw-r--r-- | src/client.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/client.rs b/src/client.rs index 0625443..c6ae1f1 100644 --- a/src/client.rs +++ b/src/client.rs @@ -22,10 +22,16 @@ pub struct Client<'a> { } impl<'a> Client<'a> { - pub fn new(token: &str, owner: &'a str, repo: &'a str) -> Self { - let client = Github::new(&token).unwrap(); - - Client { client, owner, repo } + pub fn new( + token: &str, + owner: &'a str, repo: &'a str, + ) -> Result<Self, Error> { + let client = match Github::new(&token) { + Ok(g) => g, + Err(e) => return Err(Error::Github(e.to_string())), + }; + + Ok(Client { client, owner, repo }) } pub fn fetch(&self, id: &str) -> Result<Suggestion, Error> { |