[ox/claw] Improve Claw read error reporting
This commit is contained in:
parent
1372ea9bc9
commit
a092c393a6
8
deps/ox/src/ox/claw/read.cpp
vendored
8
deps/ox/src/ox/claw/read.cpp
vendored
@ -15,7 +15,7 @@ namespace ox {
|
|||||||
Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcept {
|
Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcept {
|
||||||
const auto s1End = ox_strchr(buff, ';', buffLen);
|
const auto s1End = ox_strchr(buff, ';', buffLen);
|
||||||
if (!s1End) {
|
if (!s1End) {
|
||||||
return OxError(1);
|
return OxError(1, "Could not read Claw header");
|
||||||
}
|
}
|
||||||
const auto s1Size = s1End - buff;
|
const auto s1Size = s1End - buff;
|
||||||
String fmt(buff, s1Size);
|
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);
|
const auto s2End = ox_strchr(buff, ';', buffLen);
|
||||||
if (!s2End) {
|
if (!s2End) {
|
||||||
return OxError(1);
|
return OxError(2, "Could not read Claw header");
|
||||||
}
|
}
|
||||||
const auto s2Size = s2End - buff;
|
const auto s2Size = s2End - buff;
|
||||||
String typeName(buff, s2Size);
|
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);
|
const auto s3End = ox_strchr(buff, ';', buffLen);
|
||||||
if (!s3End) {
|
if (!s3End) {
|
||||||
return OxError(1);
|
return OxError(3, "Could not read Claw header");
|
||||||
}
|
}
|
||||||
const auto s3Size = s3End - buff;
|
const auto s3Size = s3End - buff;
|
||||||
String versionStr(buff, s3Size);
|
String versionStr(buff, s3Size);
|
||||||
@ -46,7 +46,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
|
|||||||
} else if (fmt == "O1") {
|
} else if (fmt == "O1") {
|
||||||
hdr.fmt = ClawFormat::Organic;
|
hdr.fmt = ClawFormat::Organic;
|
||||||
} else {
|
} else {
|
||||||
return OxError(1);
|
return OxError(4, "Claw format does not match any supported format/version combo");
|
||||||
}
|
}
|
||||||
hdr.typeName = typeName;
|
hdr.typeName = typeName;
|
||||||
if (auto r = ox_atoi(versionStr.c_str()); r.error == 0) {
|
if (auto r = ox_atoi(versionStr.c_str()); r.error == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user