summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/serve.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/serve.rs b/src/serve.rs
index 67d49ae..08f3f8b 100644
--- a/src/serve.rs
+++ b/src/serve.rs
@@ -16,11 +16,12 @@ lazy_static! {
pub fn get_tracks(name: String, url: String) -> Result<(), status::Custom<String>> {
let mut guard = CACHE.lock().or(Err(status::Custom(
Status::InternalServerError,
- String::new(),
+ String::from("failed to lock cache mutex"),
)))?;
- let mut oauth = guard
- .remove(&name)
- .ok_or(status::Custom(Status::NotFound, String::new()))?;
+ let mut oauth = guard.remove(&name).ok_or(status::Custom(
+ Status::NotFound,
+ String::from("uuid not found in cache"),
+ ))?;
println!("auth: {:?} url: {}", oauth, url);
let token_info = process_token(&mut oauth, &mut ("?code=".to_owned() + url.as_ref()));
let client_credential = SpotifyClientCredentials::default()
@@ -33,7 +34,7 @@ pub fn get_tracks(name: String, url: String) -> Result<(), status::Custom<String
let user_id = spotify.current_user().unwrap().id;
let mut client = crate::CLIENT.lock().or(Err(status::Custom(
Status::InternalServerError,
- String::new(),
+ String::from("failed to lock cache mutex"),
)))?;
client
.execute(
@@ -175,7 +176,6 @@ pub fn token(name: String) -> Result<Redirect, status::Custom<String>> {
fn get_uid(name: &str, client: &mut postgres::Client) -> Option<i32> {
match client.query("SELECT user_id FROM suser where user_name = $1;", &[&name]) {
- _ => None,
Ok(rows) => match rows.len() {
0 => None,
x => {
@@ -183,6 +183,7 @@ fn get_uid(name: &str, client: &mut postgres::Client) -> Option<i32> {
Some(x)
}
},
+ _ => None,
}
}