mindustry logic execution, map- and schematic- parsing and rendering
Make error messages conform to API guidelines
| -rw-r--r-- | src/block/logic.rs | 20 | ||||
| -rw-r--r-- | src/block/mod.rs | 4 | ||||
| -rw-r--r-- | src/block/power.rs | 2 | ||||
| -rw-r--r-- | src/content.rs | 4 | ||||
| -rw-r--r-- | src/data/base64.rs | 10 | ||||
| -rw-r--r-- | src/data/dynamic.rs | 26 | ||||
| -rw-r--r-- | src/data/mod.rs | 6 | ||||
| -rw-r--r-- | src/data/schematic.rs | 38 | ||||
| -rw-r--r-- | src/exe/args.rs | 16 | ||||
| -rw-r--r-- | src/team.rs | 2 |
10 files changed, 64 insertions, 64 deletions
diff --git a/src/block/logic.rs b/src/block/logic.rs index aea9d47..84c97b6 100644 --- a/src/block/logic.rs +++ b/src/block/logic.rs @@ -321,11 +321,11 @@ impl fmt::Display for ProcessorDeserializeError { Self::Read(e) => e.fmt(f), Self::Decompress(e) => e.fmt(f), - Self::DecompressStall => write!(f, "Decompressor stalled before completion"), + Self::DecompressStall => write!(f, "decompressor stalled before completion"), Self::FromUtf8(e) => e.fmt(f), - Self::Version(ver) => write!(f, "Unsupported version ({ver})"), - Self::CodeLength(len) => write!(f, "Invalid code length ({len})"), - Self::LinkCount(cnt) => write!(f, "Invalid link count ({cnt})"), + Self::Version(ver) => write!(f, "unsupported version ({ver})"), + Self::CodeLength(len) => write!(f, "invalid code length ({len})"), + Self::LinkCount(cnt) => write!(f, "invalid link count ({cnt})"), } } } @@ -388,8 +388,8 @@ impl fmt::Display for ProcessorSerializeError { Self::Write(e) => e.fmt(f), Self::Compress(e) => e.fmt(f), - Self::CompressEof(remain) => write!(f, "Compression overflow with {remain} bytes of input remaining"), - Self::CompressStall => write!(f, "Compressor stalled before completion"), + Self::CompressEof(remain) => write!(f, "compression overflow with {remain} bytes of input remaining"), + Self::CompressStall => write!(f, "compressor stalled before completion"), } } } @@ -530,7 +530,7 @@ impl fmt::Display for CodeError { match self { - Self::TooLong(len) => write!(f, "Code too long ({len} bytes)"), + Self::TooLong(len) => write!(f, "code too long ({len} bytes)"), } } } @@ -551,9 +551,9 @@ impl fmt::Display for CreateError { match self { - Self::NameLength(len) => write!(f, "Link name too long ({len} bytes)"), - Self::DuplicateName(name) => write!(f, "There already is a link named {name}"), - Self::DuplicatePos{name, x, y} => write!(f, "Link {name} already points to {x} / {y}"), + Self::NameLength(len) => write!(f, "link name too long ({len} bytes)"), + Self::DuplicateName(name) => write!(f, "there already is a link named {name}"), + Self::DuplicatePos{name, x, y} => write!(f, "link {name} already points to {x} / {y}"), } } } diff --git a/src/block/mod.rs b/src/block/mod.rs index 3699c41..df37940 100644 --- a/src/block/mod.rs +++ b/src/block/mod.rs @@ -62,7 +62,7 @@ impl fmt::Display for DeserializeError { match self { - Self::InvalidType{have, expect} => write!(f, "Expected type {expect:?} but got {have:?}"), + Self::InvalidType{have, expect} => write!(f, "expected type {expect:?} but got {have:?}"), Self::Custom(e) => e.fmt(f), } } @@ -305,7 +305,7 @@ impl<'l> fmt::Display for RegisterError<'l> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Block {:?} already exists", self.0.get_name()) + write!(f, "block {:?} already exists", self.0.get_name()) } } diff --git a/src/block/power.rs b/src/block/power.rs index aa09633..04c9607 100644 --- a/src/block/power.rs +++ b/src/block/power.rs @@ -122,7 +122,7 @@ impl fmt::Display for ConnectorDeserializeError { match self { - Self::LinkCount{have, max} => write!(f, "Too many links ({have} but only {max} supported)"), + Self::LinkCount{have, max} => write!(f, "too many links ({have} but only {max} supported)"), } } } diff --git a/src/content.rs b/src/content.rs index b7bfb9e..d0f7df4 100644 --- a/src/content.rs +++ b/src/content.rs @@ -10,7 +10,7 @@ macro_rules!numeric_enum { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "No variant of {} for value {}", stringify!($tname), self.0) + write!(f, "no variant of {} for value {}", stringify!($tname), self.0) } } @@ -86,7 +86,7 @@ macro_rules!content_enum { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "No content of type {} for value {}", stringify!($ctype), self.0) + write!(f, "no content of type {} for value {}", stringify!($ctype), self.0) } } diff --git a/src/data/base64.rs b/src/data/base64.rs index a0eb3dc..8475f42 100644 --- a/src/data/base64.rs +++ b/src/data/base64.rs @@ -178,10 +178,10 @@ impl fmt::Display for DecodeError { match self { - DecodeError::Malformed{at, value} => write!(f, "Malformed base64 character {value:?} (at {at})"), - DecodeError::Overflow{need, have} => write!(f, "Decoder overflow (need {need}, but only have {have})"), - DecodeError::Truncated => write!(f, "Truncated base64 input stream"), - DecodeError::TrailingData{at} => write!(f, "Trailing data in base64 stream (at {at})"), + DecodeError::Malformed{at, value} => write!(f, "malformed base64 character {value:?} (at {at})"), + DecodeError::Overflow{need, have} => write!(f, "decoder overflow (need {need}, but only have {have})"), + DecodeError::Truncated => write!(f, "truncated base64 input stream"), + DecodeError::TrailingData{at} => write!(f, "trailing data in base64 stream (at {at})"), } } } @@ -200,7 +200,7 @@ impl fmt::Display for EncodeError { match self { - EncodeError::Overflow{need, have} => write!(f, "Encoder overflow (need {need}, but only have {have})"), + EncodeError::Overflow{need, have} => write!(f, "encoder overflow (need {need}, but only have {have})"), } } } diff --git a/src/data/dynamic.rs b/src/data/dynamic.rs index 4a8ccde..f87c1ac 100644 --- a/src/data/dynamic.rs +++ b/src/data/dynamic.rs @@ -449,14 +449,14 @@ impl fmt::Display for ReadError match self { ReadError::Underlying(e) => e.fmt(f), - ReadError::Type(id) => write!(f, "Invalid dynamic data type ({id})"), - ReadError::IntArrayLen(len) => write!(f, "Integer array too long ({len})"), - ReadError::Point2ArrayLen(len) => write!(f, "Point2 array too long ({len})"), - ReadError::LogicField(id) => write!(f, "Invalid logic field ({id})"), - ReadError::ByteArrayLen(len) => write!(f, "Byte array too long ({len})"), - ReadError::UnitCommand(id) => write!(f, "Invalid unit command ({id})"), - ReadError::BoolArrayLen(len) => write!(f, "Boolean array too long ({len})"), - ReadError::Vec2ArrayLen(len) => write!(f, "Vec2 array too long ({len})"), + ReadError::Type(id) => write!(f, "invalid dynamic data type ({id})"), + ReadError::IntArrayLen(len) => write!(f, "integer array too long ({len})"), + ReadError::Point2ArrayLen(len) => write!(f, "point2 array too long ({len})"), + ReadError::LogicField(id) => write!(f, "invalid logic field ({id})"), + ReadError::ByteArrayLen(len) => write!(f, "byte array too long ({len})"), + ReadError::UnitCommand(id) => write!(f, "invalid unit command ({id})"), + ReadError::BoolArrayLen(len) => write!(f, "boolean array too long ({len})"), + ReadError::Vec2ArrayLen(len) => write!(f, "vec2 array too long ({len})"), } } } @@ -499,11 +499,11 @@ impl fmt::Display for WriteError match self { WriteError::Underlying(e) => e.fmt(f), - WriteError::IntArrayLen(len) => write!(f, "Integer array too long ({len})"), - WriteError::Point2ArrayLen(len) => write!(f, "Point2 array too long ({len})"), - WriteError::ByteArrayLen(len) => write!(f, "Byte array too long ({len})"), - WriteError::BoolArrayLen(len) => write!(f, "Boolean array too long ({len})"), - WriteError::Vec2ArrayLen(len) => write!(f, "Vec2 array too long ({len})"), + WriteError::IntArrayLen(len) => write!(f, "integer array too long ({len})"), + WriteError::Point2ArrayLen(len) => write!(f, "point2 array too long ({len})"), + WriteError::ByteArrayLen(len) => write!(f, "byte array too long ({len})"), + WriteError::BoolArrayLen(len) => write!(f, "boolean array too long ({len})"), + WriteError::Vec2ArrayLen(len) => write!(f, "vec2 array too long ({len})"), } } } diff --git a/src/data/mod.rs b/src/data/mod.rs index e68200b..cdf1b30 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -114,7 +114,7 @@ impl fmt::Display for ReadError { match self { - ReadError::Underflow{need, have} => write!(f, "Buffer underflow (expected {need} but got {have})"), + ReadError::Underflow{need, have} => write!(f, "buffer underflow (expected {need} but got {have})"), ReadError::Utf8(e) => e.fmt(f), } } @@ -261,8 +261,8 @@ impl fmt::Display for WriteError { match self { - WriteError::Overflow{need, have} => write!(f, "Buffer overflow (expected {need} but got {have})"), - WriteError::TooLong{len} => write!(f, "String too long ({len} bytes of {})", u16::MAX), + WriteError::Overflow{need, have} => write!(f, "buffer overflow (expected {need} but got {have})"), + WriteError::TooLong{len} => write!(f, "string too long ({len} bytes of {})", u16::MAX), } } } diff --git a/src/data/schematic.rs b/src/data/schematic.rs index d0928f1..53c73fd 100644 --- a/src/data/schematic.rs +++ b/src/data/schematic.rs @@ -448,8 +448,8 @@ impl fmt::Display for NewError { match self { - NewError::Width(w) => write!(f, "Invalid schematic width ({w})"), - NewError::Height(h) => write!(f, "Invalid schematic height ({h})"), + NewError::Width(w) => write!(f, "invalid schematic width ({w})"), + NewError::Height(h) => write!(f, "invalid schematic height ({h})"), } } } @@ -469,7 +469,7 @@ impl fmt::Display for PosError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Position {x} / {y} out of bounds {w} / {h}", x = self.x, y = self.y, w = self.w, h = self.h) + write!(f, "position {x} / {y} out of bounds {w} / {h}", x = self.x, y = self.y, w = self.w, h = self.h) } } @@ -497,8 +497,8 @@ impl fmt::Display for PlaceError { match self { - PlaceError::Bounds{x, y, sz, w, h} => write!(f, "Block placement {x} / {y} (size {sz}) within {w} / {h}"), - PlaceError::Overlap{x, y} => write!(f, "Overlapping an existing block at {x} / {y}"), + PlaceError::Bounds{x, y, sz, w, h} => write!(f, "block placement {x} / {y} (size {sz}) within {w} / {h}"), + PlaceError::Overlap{x, y} => write!(f, "overlapping an existing block at {x} / {y}"), PlaceError::Deserialize(e) => e.fmt(f), } } @@ -980,15 +980,15 @@ impl fmt::Display for ReadError match self { ReadError::Read(e) => e.fmt(f), - ReadError::Header(hdr) => write!(f, "Incorrect header ({hdr:08X})"), - ReadError::Version(ver) => write!(f, "Unsupported version ({ver})"), + ReadError::Header(hdr) => write!(f, "incorrect header ({hdr:08X})"), + ReadError::Version(ver) => write!(f, "unsupported version ({ver})"), ReadError::Decompress(e) => e.fmt(f), - ReadError::DecompressStall => write!(f, "Decompressor stalled before completion"), - ReadError::Dimensions(w, h) => write!(f, "Invalid schematic dimensions ({w} * {h})"), - ReadError::TableSize(cnt) => write!(f, "Invalid block table size ({cnt})"), - ReadError::NoSuchBlock(name) => write!(f, "Unknown block {name:?}"), - ReadError::BlockCount(cnt) => write!(f, "Invalid total block count ({cnt})"), - ReadError::BlockIndex(idx, cnt) => write!(f, "Invalid block index ({idx} / {cnt})"), + ReadError::DecompressStall => write!(f, "decompressor stalled before completion"), + ReadError::Dimensions(w, h) => write!(f, "invalid schematic dimensions ({w} * {h})"), + ReadError::TableSize(cnt) => write!(f, "invalid block table size ({cnt})"), + ReadError::NoSuchBlock(name) => write!(f, "unknown block {name:?}"), + ReadError::BlockCount(cnt) => write!(f, "invalid total block count ({cnt})"), + ReadError::BlockIndex(idx, cnt) => write!(f, "invalid block index ({idx} / {cnt})"), ReadError::BlockState(e) => e.fmt(f), ReadError::Placement(e) => e.fmt(f), } @@ -1061,14 +1061,14 @@ impl fmt::Display for WriteError { match self { - WriteError::Write(..) => write!(f, "Failed to write data to buffer"), - WriteError::TagCount(cnt) => write!(f, "Invalid tag count ({cnt})"), - WriteError::TableSize(cnt) => write!(f, "Invalid block table size ({cnt})"), + WriteError::Write(..) => write!(f, "failed to write data to buffer"), + WriteError::TagCount(cnt) => write!(f, "invalid tag count ({cnt})"), + WriteError::TableSize(cnt) => write!(f, "invalid block table size ({cnt})"), WriteError::StateSerialize(e) => e.fmt(f), - WriteError::BlockState(..) => write!(f, "Failed to write block state"), + WriteError::BlockState(..) => write!(f, "failed to write block state"), WriteError::Compress(e) => e.fmt(f), - WriteError::CompressEof(remain) => write!(f, "Compression overflow with {remain} bytes of input remaining"), - WriteError::CompressStall => write!(f, "Compressor stalled before completion"), + WriteError::CompressEof(remain) => write!(f, "compression overflow with {remain} bytes of input remaining"), + WriteError::CompressStall => write!(f, "compressor stalled before completion"), } } } diff --git a/src/exe/args.rs b/src/exe/args.rs index 6e0742c..e2ba8ef 100644 --- a/src/exe/args.rs +++ b/src/exe/args.rs @@ -29,7 +29,7 @@ impl<E: error::Error + 'static> fmt::Display for Error<E> match self { Error::Handler{pos, val} => write!(f, "{val} (at #{pos})"), - Error::EmptyName{pos} => write!(f, "Malformed argument (at #{pos})"), + Error::EmptyName{pos} => write!(f, "malformed argument (at #{pos})"), } } } @@ -447,7 +447,7 @@ impl<'l> fmt::Display for AddArgError<'l> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Duplicate argument {} (already have {})", self.to_add, self.existing) + write!(f, "duplicate argument {} (already have {})", self.to_add, self.existing) } } @@ -498,14 +498,14 @@ impl fmt::Display for OptionError { match self { - OptionError::NoSuchShort(short) => write!(f, "Invalid argument \"-{short}\""), - OptionError::NoSuchLong(long) => write!(f, "Invalid argument \"--{long}\""), - OptionError::ValueForbidden(opt) => write!(f, "Argument {opt} has no value"), - OptionError::ValueRequired(opt) => write!(f, "Argument {opt} requires a value"), + OptionError::NoSuchShort(short) => write!(f, "invalid argument \"-{short}\""), + OptionError::NoSuchLong(long) => write!(f, "invalid argument \"--{long}\""), + OptionError::ValueForbidden(opt) => write!(f, "argument {opt} has no value"), + OptionError::ValueRequired(opt) => write!(f, "argument {opt} requires a value"), OptionError::TooMany(opt) => { - if let Some(max) = opt.count.get_max_count() {write!(f, "Too many {opt} (max {max})")} - else {write!(f, "Duplicate argument {opt}")} + if let Some(max) = opt.count.get_max_count() {write!(f, "too many {opt} (max {max})")} + else {write!(f, "duplicate argument {opt}")} }, } } diff --git a/src/team.rs b/src/team.rs index 123d996..edd5ec0 100644 --- a/src/team.rs +++ b/src/team.rs @@ -78,7 +78,7 @@ impl fmt::Display for TryFromU16Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "No content of type Team for value {}", self.0) + write!(f, "no content of type Team for value {}", self.0) } } |