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

Remove logging of ApplicationException #4569

Closed

Conversation

pikanji
Copy link
Contributor

@pikanji pikanji commented Aug 26, 2019

This fix resolves #4568 .

Even though logging is suppressed by this dontReport list, ApplicationException is logged by ErrorHandler.
ErrorHandler::beforeHandleError is the one that logging ApplicationException.
It is called by ErrorHandler::handleException, which is called in the listener of exception.beforeRender event registered by ServiceProvider::registerErrorHandler

@LukeTowers
Copy link
Contributor

@pikanji ApplicationException was added in January 2015: octobercms/library@6a68036. Logging was added in February 2015 (7b52e07#diff-547f5794a63e9f138c33b20de8649b7eR20-R31)

We'll need to get @daftspunk to make the decision on this one.

@bennothommo
Copy link
Contributor

bennothommo commented Sep 16, 2019

@LukeTowers my two cents - given that it's mentioned twice that it is not meant to be logged, and it's only been added ad-hoc to the ErrorHandler to be logged, I think it's probably a safe bet it is not meant to be logged.

@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this is still being worked on, please respond and we will re-open this pull request.

@daftspunk
Copy link
Member

This looks like it might have been a typo, it should read SystemException. Overall October's platform makes inconsistent use of these exceptions likely because of the general confusion around their meaning.

To clarify the difference:

  • SystemException occurs when something unhealthy happened within the system. It couldn't write to the disk. The database has fallen over. An unhappy path has occurred due to a failure in the running system itself, either by configuration or environment or by a logic error from the programmer. In a perfect world, a System Exception should never happen.

  • ApplicationException occurs when the user has caused something to go wrong. They've filled out a form incorrectly. They didn't follow a procedure properly. These are treated as basic validation errors usually deriving from an expected path in the software where the application is not being used correctly. In a normal operating environment, Application Exceptions are likely to occur frequently.

It would appear October in general needs an overall audit to ensure the correct use of these exception types is applied.

It would also make sense that SystemException is logged, but ApplicationException probably shouldn't be logged by default.

@daftspunk
Copy link
Member

daftspunk commented Nov 6, 2019

I'm leaving this open because it contains actionable information but the current code itself should not get merged; ApplicationException should be renamed to SystemException.

@LukeTowers
Copy link
Contributor

@daftspunk do you mean rename the exception class itself? I use it all the time in my project's for its intended purpose, telling the user they've done something wrong.

@daftspunk
Copy link
Member

I mean don't log messages that tell the user they've done something wrong, only log system errors.

Change code to this, but maybe look at the impact of doing so first:

    /**
     * We are about to display an error page to the user,
     * if it is an SystemException, this event should be logged.
     * @return void
     */
    public function beforeHandleError($exception)
    {
        if ($exception instanceof SystemException) {
            Log::error($exception);
        }
    }

@LukeTowers
Copy link
Contributor

Did a quick look through the core, all SystemException uses right now are valid, they're mostly used for cases where either the system trips on something that it can't recover from or as a "developer validation" tool (i.e. perhaps it could recover from it, but the developer should really just follow the error message to fix whatever it is they're doing wrong).

@daftspunk daftspunk closed this Dec 10, 2019
daftspunk added a commit that referenced this pull request Dec 10, 2019
This appears to be a typoe. It doesn't make sense to ever log "user errors", only "system errors"

Fixes #4569
LukeTowers added a commit that referenced this pull request Aug 28, 2020
SystemExceptions are already logged when the System ServiceProvider listens to the Message Logged event, this code used to be for ApplicationExceptions to bypass the fact that they were explicitly ignored by October's core exception handler.

ApplicationExceptions were added 27 Jan 2015 in octobercms/library@6a68036
ApplicationExceptions were explicitly ignored in the core exception handler on 16 Feb 2015 in octobercms/library@237d97d#diff-b6bf0348130fdd1311473a97536310cdR20 and were explicitly logged in the System exception handler on the same day in 7b52e07#diff-547f5794a63e9f138c33b20de8649b7eR20-R31

Not sure why that was originally the case, but we've made the decision that ApplicationExceptions shouldn't be logged by default as they should occur semi-regularly in a healthy application (mostly as an expression of complex logical validation that triggers them based on bad user input): #4569 (comment)

Fixes #5253.
LukeTowers added a commit to octoberrain/system that referenced this pull request Sep 4, 2020
SystemExceptions are already logged when the System ServiceProvider listens to the Message Logged event, this code used to be for ApplicationExceptions to bypass the fact that they were explicitly ignored by October's core exception handler.

ApplicationExceptions were added 27 Jan 2015 in octobercms/library@6a68036
ApplicationExceptions were explicitly ignored in the core exception handler on 16 Feb 2015 in octobercms/library@237d97d#diff-b6bf0348130fdd1311473a97536310cdR20 and were explicitly logged in the System exception handler on the same day in octobercms/october@7b52e07#diff-547f5794a63e9f138c33b20de8649b7eR20-R31

Not sure why that was originally the case, but we've made the decision that ApplicationExceptions shouldn't be logged by default as they should occur semi-regularly in a healthy application (mostly as an expression of complex logical validation that triggers them based on bad user input): octobercms/october#4569 (comment)

Fixes octobercms/october#5253.
daftspunk pushed a commit to octoberrain/system that referenced this pull request Mar 5, 2021
SystemExceptions are already logged when the System ServiceProvider listens to the Message Logged event, this code used to be for ApplicationExceptions to bypass the fact that they were explicitly ignored by October's core exception handler.

ApplicationExceptions were added 27 Jan 2015 in octobercms/library@6a68036
ApplicationExceptions were explicitly ignored in the core exception handler on 16 Feb 2015 in octobercms/library@237d97d#diff-b6bf0348130fdd1311473a97536310cdR20 and were explicitly logged in the System exception handler on the same day in octobercms/october@7b52e07#diff-547f5794a63e9f138c33b20de8649b7eR20-R31

Not sure why that was originally the case, but we've made the decision that ApplicationExceptions shouldn't be logged by default as they should occur semi-regularly in a healthy application (mostly as an expression of complex logical validation that triggers them based on bad user input): octobercms/october#4569 (comment)

Fixes octobercms/october#5253.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants