Skip to content

Conversation

dlecorfec
Copy link
Contributor

Encountered the following error message on a bad STL file:
astisub: building gsi block failed: astisub: atoi of � failed: strconv.Atoi: parsing "\x01": invalid syntax

Decided to replace the second occurence of "astisub" with the name of the target variable, in every place with int or date parsing, so this PR will output:
astisub: building gsi block failed: totalNumberOfDisks: atoi of failed: strconv.Atoi: parsing "\x01": invalid syntax
which makes it easier to pinpoint the bad location in the STL file.

(one could also wonder if it would be worth it to replace the %s of "atoi of %s failed" with a %q, in case of a non-printable string like in this example ...)

Bonus, line 835, removed the "astisub: " prefix which is redundant with the message line 206 in ReadFromSTL().

@asticode
Copy link
Owner

asticode commented Sep 1, 2025

Adding the field targeted by the error is a good idea, however I'd rather keep the astisub: prefix which is there to indicate which package is submitting the error. Could you update error messages like astisub: totalNumberOfDisks atoi of %q failed: %w and revert the prefix you've removed line 835?

@dlecorfec
Copy link
Contributor Author

Indeed, before submitting this PR, I checked that the astisub: prefix was already present in the public function (ReadFromSTL) of the package, which calls private functions (parseGSIBlock and newSTLCharacterHandler), where I removed the dups. So there's still an astisub: prefix (on line 199 and 206) indicating the package submitting the error.

@dlecorfec
Copy link
Contributor Author

I added a change to ignore the Atoi errors when parsing TND and DSN: we encounter some STL with binary "1" instead of ASCII "1", and those values have no interests when convertings subs anyways (plus ttconv also ignores them).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants