NAME

DBIx::Squirrel::Stop - end a DBIx::Squirrel pipeline early

SYNOPSIS

use DBIx::Squirrel::Stop;

# In a stage of a pipeline
sub ($row) { Stop() if $done; ... }

# Stop, passing on a last value
sub ($row) { $row->{id} == $wanted ? Stop($row) : () }

# The same, without importing Stop
sub ($row) { DBIx::Squirrel::Stop->throw if $done; ... }

DESCRIPTION

DBIx::Squirrel's pipeline is Ekorn::Pipeline's, and this module is DBIx::Squirrel's name for Ekorn::Pipeline::Stop, which describes the stop in full. It's a subclass of it, and exports Stop, by default: Ekorn's function, from a list of DBIx::Squirrel's own. It's here to stay, so code written with it keeps working.

A stop is the exception that ends a pipeline early and quietly. The rest of the stage that throws it doesn't run. The values already out of the pipeline are kept, the values the stop carries go on through the stages after it, and nothing else is processed.

FUNCTIONS

Stop

Stop();
Stop(@values);

Throws a stop carrying @values. It's "Stop" in Ekorn::Pipeline::Stop, so the stop is an Ekorn::Pipeline::Stop. To keep it out of your namespace:

use DBIx::Squirrel::Stop ();

METHODS

throw

DBIx::Squirrel::Stop->throw(@values);
My::Stop->throw(@values);

Inherited from "throw" in Ekorn::Pipeline::Stop: throws a stop carrying @values, blessed into the class it was called on. A subclass of DBIx::Squirrel::Stop is a subclass of Ekorn::Pipeline::Stop too, so the pipeline stops for it.

Catching errors in a stage

A stage that catches errors itself, with eval or try, should throw a stop on again. Check for Ekorn::Pipeline::Stop, which every stop is, whether thrown with Stop, by this class, or by a canned stage such as take:

sub ($row) {
    try { ... }
    catch ($e) {
        die $e if $e isa 'Ekorn::Pipeline::Stop';
        ...
    }
}

Checking for DBIx::Squirrel::Stop would miss the stops that aren't thrown by this class.

DIAGNOSTICS

Stop used outside a pipeline

A stop was thrown where no pipeline was running to catch it.

SEE ALSO

Ekorn::Pipeline::Stop, DBIx::Squirrel

AUTHOR

Iain Campbell <cpanic@cpan.org>

LICENSE

Copyright (c) 2024-2026 by Iain Campbell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.