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

catch RejectedItemExceptions and log them instead of stopping the pipeline #27

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

clemzarch
Copy link
Contributor

avant:

public function transform() : \Generator
{
    $line = yield;
    do {
        $line = ($this->mapper)($line, $line);
    } while ($line = (yield new \Kiboko\Component\Bucket\AcceptanceResultBucket($line)));
    (yield new \Kiboko\Component\Bucket\AcceptanceResultBucket($line));
}

après:

public function transform() : \Generator
{
    $input = yield;
    while ($input !== null) {
        try {
            $line = ($this->mapper)($input, $input);
        } catch (\Kiboko\Contract\Pipeline\RejectedItemException $exception) {
            $this->logger->error($exception->getMessage(), array('input' => $input));
            $input = (yield new \Kiboko\Component\Bucket\RejectionResultBucket($input));
            continue;
        }
        $input = (yield new \Kiboko\Component\Bucket\AcceptanceResultBucket($line));
    }
    (yield new \Kiboko\Component\Bucket\AcceptanceResultBucket($input));
}

@clemzarch clemzarch added the GTM Good to merge label Aug 29, 2023
@clemzarch clemzarch self-assigned this Aug 29, 2023
@gplanchat gplanchat merged commit be948a8 into main Jan 12, 2024
@gplanchat gplanchat deleted the feature/catch-logs branch January 12, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GTM Good to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants