Merge pull request #138 from librespot-org/authpanic

Add error message to auth failure case
This commit is contained in:
Sasha Hilton 2018-02-13 23:19:05 +01:00 committed by GitHub
commit 874cc541de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,6 +34,7 @@ pub fn authenticate(
device_id: String,
) -> Box<Future<Item = (Transport, Credentials), Error = io::Error>> {
use protocol::authentication::{APWelcome, ClientResponseEncrypted, CpuFamily, Os};
use protocol::keyexchange::APLoginFailed;
let mut packet = ClientResponseEncrypted::new();
packet
@ -79,7 +80,11 @@ pub fn authenticate(
Ok((transport, reusable_credentials))
}
Some((0xad, _)) => panic!("Authentication failed"),
Some((0xad, data)) => {
let error_data: APLoginFailed = protobuf::parse_from_bytes(data.as_ref()).unwrap();
panic!("Authentication failed with reason: {:?}", error_data.get_error_code())
}
Some((cmd, _)) => panic!("Unexpected packet {:?}", cmd),
None => panic!("EOF"),
}),