Skip to content

Catch an error while importing huge CSV in queue using laravel excel #3

@shashankdevstree

Description

@shashankdevstree

I am using ShouldQueue method to have the large CSV into Queue but the errors of validations I am not able to catch them!

public function registerEvents(): array { return [ ImportFailed::class => function(ImportFailed $event) { dd($event); // This I will write into the FILE or send EMAIL but the job runs successfully but validation errors keep empty. $this->importedBy->notify(new ImportHasFailedNotification); }, ]; }

My code looks like below...

public function registerEvents(): array { return [ ImportFailed::class => function(ImportFailed $event) { $filename = public_path('tmp').'/validation_error.txt'; $myfile = fopen($filename, "w"); fwrite($myfile, "domo"); fclose($myfile); }, ]; }

I am in hope that if there is any error validation_error.txt file will have "Demo" inside it.

I just wanted to add those errors in a file and email to the user that's it.

Also, I have crossed verify by removing ShouldQueue it gives me proper errors for email already exists a kind of.

Please help if you have any ideas! Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions