Skip to content

Exception message override log message #631

Closed

Description

@armetiz

Hi there.

try {
    throw new \RuntimeException('Not yet implemented.');
} catch (\Throwable $exception) {
    $this->logger->error('User could not be registered.', [
        'exception' => $exception,
    ]);
}

The above Rollbar logged event message is : Not yet implemented.
It should be User could not be registered.

Activity

  1. self-assigned this
    on Oct 13, 2023
  2. danielmorell commented on Oct 13, 2023

    @danielmorell
    Collaborator

    Hey Thomas, thank you for reporting this!

    I took a look at the implementation and User could not be registered. is being sent as the description if a Throwable is provided in the 'exception' context. I agree this is probably backwards of the way I would have expected it given your code example above.

    Given there are two messages associated with the error, we have three options (at least that I can think of):

    1. Send the Not yet implemented. as the message and User could not be registered. as the description.
    2. Send the User could not be registered. as the message and Not yet implemented. as the description.
    3. Concatenate the two into one message e.g. User could not be registered. (Not yet implemented.).

    I think I lean toward option 3. What do you think?

  3. armetiz commented on Oct 16, 2023

    @armetiz
    ContributorAuthor

    Hi @danielmorell ,
    I think option 2. is the best one! This seems obvious to me because it respects developper intention's.

    On the above example, you can see the exception line, but in real application errors are thrown in deeper code. When receiving Rollbar alert, developpers knows about theirs codes, but if message is related to a librairy exception.. It's really hard to understand on first sight.

    Option 1 is inappropriate.
    Option 3 : this is not a bad idea

  4. added 2 commits that reference this issue on Dec 15, 2023
    359fe76
    59e0360
  5. added a commit that references this issue on Dec 22, 2023
    72fc135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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