simonw/shot-scraper

--fail-on-error overlaps with --fail

Closed this issue · 3 comments

When I built --fail in #102 I missed that shot-scraper multi already has a similar option, --fail-on-error.

That option turns out to not do much though:

@click.option(
"--timeout",
type=int,
help="Wait this many milliseconds before failing",
)
@click.option("--fail-on-error", is_flag=True, help="Fail noisily on error")

except TimeoutError as e:
if fail_on_error:
raise click.ClickException(str(e))
else:
click.echo(str(e), err=True)
continue

That's the only place it actually has an impact: if a page times out and --fail-on-error is set then you get an error, otherwise it gets skipped.

That option was added in: 68fe390

See also:

Potential solutions:

  • Leave it alone.
  • Deprecate --fail-on-error - use hidden=True to hide it from --help - but have --fail also handle that timeout case

Demo:

% echo '- url: https://datasette.io/' | shot-scraper multi - --timeout 1 --fail
Error: Timeout 1ms exceeded.
=========================== logs ===========================
navigating to "https://datasette.io/", waiting until "load"
============================================================
% echo $?                                                                      
1
% echo '- url: https://datasette.io/' | shot-scraper multi - --timeout 1       
Timeout 1ms exceeded.
=========================== logs ===========================
navigating to "https://datasette.io/", waiting until "load"
============================================================
% echo $?                                                               
0