Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

sending emails on warnings and notice error also #4

Closed
jitendrar opened this issue May 13, 2017 · 7 comments
Closed

sending emails on warnings and notice error also #4

jitendrar opened this issue May 13, 2017 · 7 comments

Comments

@jitendrar
Copy link

@ebrigham1

Thanks for the nice plugin. It is really good and solved our issues.

We have seen that this plugin only send email on fatal errors. It is not sending emails on "Database Query Errors" and warning and notice errors.

Is there way that we can able to receive those emails also. We want to make our website error free and that we can only able to do if we will going to receive each and every type of emails.

@ebrigham1
Copy link
Owner

Hi @jitendrar so glad you are finding the plugin useful. It is not currently possible to receive emails from anything but fatal errors and exceptions with this plugin. I'm going to look into the feasibility of adding emailing levels and the ability choose what level of error you get emailed about. In the meantime you should be able to see these warning/notice errors in your cake error logs (/path/to/your/cake/install/logs/error.log) assuming you're using the default configuration.

@jitendrar
Copy link
Author

Hi @ebrigham1

Thanks for quick reply.

I have also noticed that you have not added request IP address from which this error generated. Can you please also add that so we not have to do any customization in that.

Also, can you please let me know expected above changes date?

Thanks,
Jitendra

@ebrigham1
Copy link
Owner

Hi @jitendrar

I've made the changes so that now you can select what error levels you wish to be emailed about. You'll have to update your version of the plugin to 1.2.0 with composer update ebrigham1/cakephp-error-email from command line in order to receive the changes. You can see the new config information here: https://github.com/ebrigham1/cakephp-error-email#configuration The specific config key you will need to update is emailLevels. The default level is in line with the current functionality of the plugin. You'll want to update your local app.php config to contain something like:

'emailLevels' => ['exception', 'error', 'warning', 'notice', 'strict', 'deprecated'],

In order to receive an email for every possible error. Additionally I included the Client IP in the email templates. This should address your issue, if not please let me know.

@jitendrar
Copy link
Author

Hi @ebrigham1

It works great and now we are receiving all the errors as you have described. We are also getting client IP in email. Thanks for quick turn around.

One last thing needed if possible in that. We have few database related query errors which shows in browser but we are not getting error for them. Here, I have attached screen shot for that. Here, we are trying to access DB table column which is not exists. CakePHP gives it as "Database Error" (PDOException)

screenshot_3

@ebrigham1
Copy link
Owner

Hi @jitendrar

I just tested on a fresh cake install using code like this:

$query = $this->Bookmarks
    ->find()
    ->select(['id'])
    ->where(['wrong_column =' => 1]);
foreach($query as $bookmark) {
// Do something
}

It triggered the PDOException and I was emailed about the exception:

pdo_exception

Is it possible you have PDOException in your ErrorEmail.skipEmail config or in your Error.skipLog config? Another reason it might not be being sent is if you are catching the exception and handling it yourself. This plugin hooks into cakephp's global error/exception handler so it will only work on errors/exceptions which aren't caught in the app and handled by the app.

@jitendrar
Copy link
Author

Hi @ebrigham1

It is strange. It worked at your end and not worked at my end. I have not setup anything extra like Error.skipLog and ErrorEmail.skipEmail.

I have also installed fresh CakePHP and still not receiving PDOException email.

I think, I need to do some more R & D on that. If you have some time then we can chat on this on Skype and make solution otherwise I will try to do more R & D on my side.

Thanks for your help again.

@ebrigham1
Copy link
Owner

ebrigham1 commented May 17, 2017

Hi @jitendrar

That is strange one thing I notice is your debug page for that error looks a little different from mine, yours includes the raw sql generated. Are you using any plugins or have you modified your error handling in any way that this exception is maybe not using the global cake exception handler/ErrorHandlerMiddleware?

Here is my debug page for reference for the same error that generated the email

pdo_error_debug

When installing the plugin did you replace

use Cake\Error\Middleware\ErrorHandlerMiddleware;

with

use ErrorEmail\Middleware\ErrorHandlerMiddleware;

in src/Application.php

Edit: Another thing to check would be if it isn't emailing about any exceptions or just PDO ones, you could put a

throw new \Exception("something bad happened");

in some controller and see if you get an email about it, that could help narrow down the cause.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants