Skip to content

[Messenger] Add previous to the exception output #52951

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

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

ToshY
Copy link
Contributor

@ToshY ToshY commented Dec 8, 2023

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #52921
License MIT

Adds previous part of the exception to be displayed from messenger:show:failed <id> -vv command.

@ToshY ToshY changed the title added previous to the exception output [Messenger] Added previous to the exception output Dec 8, 2023
@ToshY ToshY changed the title [Messenger] Added previous to the exception output [Messenger] Add previous to the exception output Dec 8, 2023
@ToshY ToshY marked this pull request as ready for review December 8, 2023 19:19
@carsonbot carsonbot added this to the 7.1 milestone Dec 8, 2023
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
@ToshY
Copy link
Contributor Author

ToshY commented Jul 19, 2024

@xabbuh I've created this PR 8 months ago targeting 7.1, but it hasn't been merged yet. Any particular reason for it?

It would really help me out debugging failed messages if this can get merged.

@@ -188,6 +188,7 @@ private function createCloner(): ?ClonerInterface
Caster::PREFIX_VIRTUAL.'file' => $flattenException->getFile(),
Caster::PREFIX_VIRTUAL.'line' => $flattenException->getLine(),
Caster::PREFIX_VIRTUAL.'trace' => new TraceStub($flattenException->getTrace()),
Caster::PREFIX_VIRTUAL.'previous' => $flattenException->getPrevious(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it work this way as getPrevious() returns a FlattenException instance and not a scalar value? And what about calling getAllPrevious() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it work this way as getPrevious() returns a FlattenException instance and not a scalar value?

It shows the trace fine in the terminal, and gives all the information needed for further debugging.

Example:

previous: App\Exception\CustomViolationException^ {#1
    message: """
      SQLSTATE[23000]: Integrity constraint violation: ...
      """
    code: 1062
    file: "/app/src/Service/ExampleService.php"
    line: 167
    trace: {
      /app/src/Service/ExampleService.php:167 {
        App\Service\ExampleService->updateStuff(array $updateCollection): void^
        ›
        › throw new CustomViolationException(
        ›     message: $e->getMessage(),
      }
      /app/src/Service/ExampleServiceTwo.php:94 { …}

And what about calling getAllPrevious() instead?

I didn't know about getAllPrevious() but after trying it out I don't see much difference between the two except for notation.

getPrevious

previous: PDOException^ {
  message: "SQLSTATE[23000]: Integrity constraint violation: ...
}

getAllPrevious

previousAll: [
  PDOException^ {#3
    message: "SQLSTATE[23000]: Integrity constraint violation: ...
    ...
  },
  PDOException^ {#3}
]

As it seems the same to me, what do you think is best to use?

@symfony symfony deleted a comment from carsonbot Jul 20, 2024
@ToshY ToshY requested a review from xabbuh July 20, 2024 20:29
@fabpot
Copy link
Member

fabpot commented Aug 19, 2024

Thank you @ToshY.

@fabpot fabpot merged commit 99b25a1 into symfony:7.2 Aug 19, 2024
6 of 8 checks passed
@fabpot fabpot mentioned this pull request Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Messenger] Add $previous to failed message details
4 participants