stevenarella/src
ice_iix c1692e950a Improve error reporting of invalid UTF-8 when deserializing strings
std::io::Read read_to_string() [1] reports this uninformative error:

thread 'main' panicked at 'Err: IOError(Custom { kind: InvalidData, error: StringError("stream did not contain valid UTF-8") })', src/server/mod.rs:442:33

Instead of read_to_string(), use read_to_end() to read into a buffer,
then convert using String::from_utf8() and unwrap it. This gives a
better error message when UTF-8 fails to decode:

thread '' panicked at 'called Result::unwrap() on an Err value: FromUtf8Error { bytes: [105, 110, 101, 99, 114, 97, 102, 116, 58, 99, 114, 97, 102, 116, 105, 110, 103, 95, 115, 104, 97, 112, 101, 100, 20, 109, 105, 110, 101, 99, 114, 97, 102, 116, 58, 98, 111, 110, 101, 95, 98, 108, 111, 99, 107, 3, 3, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 1, 134, 5, 1, 0, 1, 249, 2, 1, 0, 25, 109], error: Utf8Error { valid_up_to: 50, error_len: Some(1) } }', src/libcore/result.rs:1009:5

which is helpful for tracking down protocol errors, such as updating to
a new protocol (developed for GH-132 / GH-72).

[1] https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_to_string
[2] https://doc.rust-lang.org/std/string/struct.String.html#method.from_utf8
2019-04-30 19:20:32 -07:00
..
console Use field init shorthand, instead of x:x, just x, 2018-11-04 13:43:30 -08:00
ecs Use field init shorthand, instead of x:x, just x, 2018-11-04 13:43:30 -08:00
entity Add double-jump to toggle creative flight. Closes #46 2019-01-26 13:00:19 -08:00
gl Update for glutin wasm_stub branch tracking Rust 2018 changes 2019-03-03 11:50:52 -08:00
model 1.13.2 (404) multiprotocol support (#67) 2018-12-28 21:22:58 -08:00
nbt 1.12.2 protocol support (340) (#40) 2018-12-02 19:37:41 -08:00
protocol Improve error reporting of invalid UTF-8 when deserializing strings 2019-04-30 19:20:32 -07:00
render Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
screen Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
server Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
types Add 18w50a (451) multiprotocol support (#79) 2019-01-10 17:21:19 -08:00
ui Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
world Add 18w50a (451) multiprotocol support (#79) 2019-01-10 17:21:19 -08:00
auth.rs Update to use crate:: for current crate, for Rust 2018 edition 2018-11-04 12:06:00 -08:00
chunk_builder.rs Use field init shorthand, instead of x:x, just x, 2018-11-04 13:43:30 -08:00
format.rs Recognize translate text components, instead of showing "UNHANDLED" 2018-12-02 19:25:11 -08:00
item.rs 1.13.2 (404) multiprotocol support (#67) 2018-12-28 21:22:58 -08:00
macros.rs Base implementation for worlds/blocks 2016-03-18 22:24:30 +00:00
main.rs Update for glutin wasm_stub branch tracking Rust 2018 changes 2019-03-03 11:50:52 -08:00
resources.rs Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
settings.rs Add double-jump to toggle creative flight. Closes #46 2019-01-26 13:00:19 -08:00