Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve(#1104): Improve error message in announce response #1105

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/servers/http/v1/extractors/announce_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ mod tests {

assert_error_response(
&response,
"Cannot parse query params for announce request: missing query params for announce request",
"Bad request. Cannot parse query params for announce request: missing query params for announce request",
);
}

Expand All @@ -146,13 +146,13 @@ mod tests {
let invalid_query = "param1=value1=value2";
let response = extract_announce_from(Some(invalid_query)).unwrap_err();

assert_error_response(&response, "Cannot parse query params");
assert_error_response(&response, "Bad request. Cannot parse query params");
}

#[test]
fn it_should_reject_a_request_with_a_query_that_cannot_be_parsed_into_an_announce_request() {
let response = extract_announce_from(Some("param1=value1")).unwrap_err();

assert_error_response(&response, "Cannot parse query params for announce request");
assert_error_response(&response, "Bad request. Cannot parse query params for announce request");
}
}
4 changes: 2 additions & 2 deletions src/servers/http/v1/requests/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ impl FromStr for Compact {
impl From<ParseQueryError> for responses::error::Error {
fn from(err: ParseQueryError) -> Self {
responses::error::Error {
failure_reason: format!("Cannot parse query params: {err}"),
failure_reason: format!("Bad request. Cannot parse query params: {err}"),
}
}
}

impl From<ParseAnnounceQueryError> for responses::error::Error {
fn from(err: ParseAnnounceQueryError) -> Self {
responses::error::Error {
failure_reason: format!("Cannot parse query params for announce request: {err}"),
failure_reason: format!("Bad request. Cannot parse query params for announce request: {err}"),
}
}
}
Expand Down