Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier way to distinguish different UnsuccessfulCommandException errors #246

Open
samwilson opened this issue Aug 24, 2024 · 0 comments
Open

Comments

@samwilson
Copy link

Currently, UnsuccessfulCommandException is used when "The command did not produce any output" (i.e. the output file was empty or nonexistent, or there was nothing on stdout), as well as "The command could not be launched" (i.e. proc_open() failed).

Both of these situations occur within TesseractOCR::run(), so it would be useful to be able to catch them separately, e.g.:

try {
    $text = $tesseractOcr->run();
} catch ( NoOutputException $e ) {
    $text = '';
} catch ( ProcessCreationException $e ) {
    // Do something.
}

It seems that the state of "The command did not produce any output" is actually a bunch of different things — and it seems fine to handle these all together, but the trouble is that one of the states is when an image actually contains no text, and it seems like this shouldn't be an error. TesseractOCR::run() should be able to return an empty string, if that's the actual OCR output.

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

No branches or pull requests

1 participant