[ox/claw] Improve Claw read error reporting

This commit is contained in:
Gary Talent 2022-03-05 11:38:20 -06:00
parent 1372ea9bc9
commit a092c393a6

View File

@ -15,7 +15,7 @@ namespace ox {
Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcept {
const auto s1End = ox_strchr(buff, ';', buffLen);
if (!s1End) {
return OxError(1);
return OxError(1, "Could not read Claw header");
}
const auto s1Size = s1End - buff;
String fmt(buff, s1Size);
@ -24,7 +24,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
const auto s2End = ox_strchr(buff, ';', buffLen);
if (!s2End) {
return OxError(1);
return OxError(2, "Could not read Claw header");
}
const auto s2Size = s2End - buff;
String typeName(buff, s2Size);
@ -33,7 +33,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
const auto s3End = ox_strchr(buff, ';', buffLen);
if (!s3End) {
return OxError(1);
return OxError(3, "Could not read Claw header");
}
const auto s3Size = s3End - buff;
String versionStr(buff, s3Size);
@ -46,7 +46,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
} else if (fmt == "O1") {
hdr.fmt = ClawFormat::Organic;
} else {
return OxError(1);
return OxError(4, "Claw format does not match any supported format/version combo");
}
hdr.typeName = typeName;
if (auto r = ox_atoi(versionStr.c_str()); r.error == 0) {