Skip Navigation

[Resolved] On-demand custom code snippets error notification but no error on trying again

This thread is resolved. Here is a description of the problem and solution.

Problem: I created a custom code snippet to run on-demand. It seems to work correctly but I see an error message in the code editor page marked "Last Error":

[2021-06-27 10:38:12, frontend] Executed code snippet "update".
Note: Depending on the nature of the error, you may need to run the script in a particular scenario to make sure the issue is gone.

Solution: It looks like the error was resolved in the code snippet but the internal test procedure was not run again after the code edits. Click "Save the snippet and try again" to run the code again through the internal test procedure. If it is successful, that should clear out the internal error log history and remove the "last error" display.

This support ticket is created 3 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by himanshuS 3 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#2100767

I have been using toolset custom code section for a lot of custom code and it works just fine.

Having said that, I decided to use the on-demand feature of the custom code to append a snippet in the URL - hidden link;

It seems to work a few times but when I go back to the custom code console, I see this error - hidden link

[2021-06-27 10:38:12, frontend] Executed code snippet "update".
Note: Depending on the nature of the error, you may need to run the script in a particular scenario to make sure the issue is gone.

When I save the snippet and try again, there is no error. What am I missing here?

#2100841

Hello, if you saw an error while you were developing the snippet, then fixed the problem and saved the code with "Save and Close" or just "Save", sometimes this happens if you tested the script with the URL parameter instead without clicking "Save and Test" or "Save the snippet and test again". The on-demand test was successful but it did not fully reset the internal snippet error log. It can be a bit confusing but does not necessarily indicate a problem. Click "Save the snippet and try again" to run the code again with the internal test procedure. If it is successful, that should clear out the internal error log history and remove the "last error" display.

If the "Last error" message appears again at some point without making any code edits, that could indicate a problem in the code. You should turn on server logs, add debug statements throughout the code, and look for more detailed information produced during future errors.

#2101537

My issue is resolved now. Thank you!