You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-07 17:03:01 +03:00
Improve errors when MAS contacts the Synapse homeserver (#2794)
* Add some drive-by docstrings * Change text rendering of catch_http_codes::HttpError Using `#[source]` is unnatural here because it makes it look like two distinct errors (one being a cause of the other), when in reality it is just one error, with 2 parts. Using `Display` formatting for that leads to a more natural error. * Add constraints to `catch_http_code{,s}` methods Not strictly required, but does two things: - documents what kind of function is expected - provides a small extra amount of type enforcement at the call site, rather than later on when you find the result doesn't implement Service * Add a `catch_http_errors` shorthand Nothing major, just a quality of life improvement so you don't have to repetitively write out what a HTTP error is * Unexpected error page: remove leading whitespace from preformatted 'details' section The extra whitespace was probably unintentional and makes the error harder to read, particularly when it wraps onto a new line unnecessarily * Capture and log Matrix errors received from Synapse * Drive-by clippy fix: use clamp instead of min().max() * Convert `err(Display)` to `err(Debug)` for `anyhow::Error`s in matrix-synapse support module
This commit is contained in:
@@ -109,7 +109,7 @@ impl Header for AcceptLanguage {
|
||||
let quality = std::str::from_utf8(quality).map_err(|_e| Error::invalid())?;
|
||||
let quality = quality.parse::<f64>().map_err(|_e| Error::invalid())?;
|
||||
// Bound the quality between 0 and 1
|
||||
let quality = quality.min(1_f64).max(0_f64);
|
||||
let quality = quality.clamp(0_f64, 1_f64);
|
||||
|
||||
// Make sure the iterator is empty
|
||||
if it.next().is_some() {
|
||||
|
Reference in New Issue
Block a user