+ Added Response::RestrictedInput to db-lib

Should make it more dsecriptive with really weird input and prevent even more confusing 500 responses to the client

+ db-lib::Channels::add now also potentially returns this new RestrictedInput variant
This commit is contained in:
shockrah
2020-12-29 23:50:57 -08:00
parent b7209c000c
commit 549c69f668
3 changed files with 24 additions and 10 deletions

View File

@@ -187,8 +187,10 @@ impl Channel {
Err(_) => Response::Empty
};
}
// TODO: change this to return Result<> which should help with ambiguity
return Response::Other("Could not fetch new channel".into());
else {
return Response::RestrictedInput(
"Could not add channel, make sure the name is unique and not longer than 256 bytes".into());
}
}
return Response::Other(no_conn!("db::channels::add"))
}

View File

@@ -25,8 +25,9 @@ pub enum Response<T> {
Empty,
// Generic success for things like update/delete's
Success,
// Duplicate keys can sometimes fuck us over for inserts/update(why tf tho)
Duplicate,
// Mask 500's with probable user generated errors like duplicate keys being added
// or data that doesn't fit in column or something
RestrictedInput(String),
// Not sure what this will be used for but maybe its useful at some point
Other(String)
}