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

Add reflection exception error message to InvalidStoredEvent exception #469

Merged

Conversation

deonvdv
Copy link
Contributor

@deonvdv deonvdv commented Jun 13, 2024

Adding this message makes debugging easier during event replay.

--
Before

Replaying 44037 events...
 37995/44037 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░]  86%
   Spatie\EventSourcing\StoredEvents\Exceptions\InvalidStoredEvent 

  

  at vendor/spatie/laravel-event-sourcing/src/StoredEvents/StoredEvent.php:121
    117▕ 
    118▕         try {
    119▕             $reflectionClass = new ReflectionClass($this->event_class);
    120▕         } catch (ReflectionException $exception) {
  ➜ 121▕             throw new InvalidStoredEvent();
    122▕         }
    123▕ 
    124▕         if ($serializerAttribute = $reflectionClass->getAttributes(EventSerializerAttribute::class)[0] ?? null) {
    125▕             $serializerClass = ($serializerAttribute->newInstance())->serializerClass;

      +20 vendor frames 

  21  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

After:

37995/44037 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░]  86%
   Spatie\EventSourcing\StoredEvents\Exceptions\InvalidStoredEvent 

  Class "App\Domains\ViewSync\StorableEvents\ViewSyncChangeCreated" does not exist

  at vendor/spatie/laravel-event-sourcing/src/StoredEvents/StoredEvent.php:121
    117▕ 
    118▕         try {
    119▕             $reflectionClass = new ReflectionClass($this->event_class);
    120▕         } catch (ReflectionException $exception) {
  ➜ 121▕             throw new InvalidStoredEvent($exception->getMessage());
    122▕         }
    123▕ 
    124▕         if ($serializerAttribute = $reflectionClass->getAttributes(EventSerializerAttribute::class)[0] ?? null) {
    125▕             $serializerClass = ($serializerAttribute->newInstance())->serializerClass;

      +20 vendor frames 

  21  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Thanks

@sebastiandedeyne sebastiandedeyne merged commit 403ae99 into spatie:main Jun 13, 2024
@sebastiandedeyne
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants