diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/git-sugapply.rs | 2 | ||||
-rw-r--r-- | src/bin/git-sugpatch.rs | 2 | ||||
-rw-r--r-- | src/client.rs | 14 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/bin/git-sugapply.rs b/src/bin/git-sugapply.rs index d569147..47d26f2 100644 --- a/src/bin/git-sugapply.rs +++ b/src/bin/git-sugapply.rs @@ -17,7 +17,7 @@ fn main() { env!("GITHUB_TOKEN"), &url.owner, &url.repo, - ); + ).unwrap(); let suggestion = client.fetch(&url.comment_id).unwrap(); diff --git a/src/bin/git-sugpatch.rs b/src/bin/git-sugpatch.rs index 08d1a38..1e21923 100644 --- a/src/bin/git-sugpatch.rs +++ b/src/bin/git-sugpatch.rs @@ -17,7 +17,7 @@ fn main() { env!("GITHUB_TOKEN"), &url.owner, &url.repo, - ); + ).unwrap(); let suggestion = client.fetch(&url.comment_id).unwrap(); 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> { |