6

Lets say I have a VF page and a controller. I would like to know why I don't see any errors coming on the log status when there are exceptions thrown when the code runs.

I am trying to deliberately make the apex code fail (throw an exception) and expect to see its failure on the log status generated in Developer Console when I open the VF page. I don't want to catch this exception. I would like to see it coming on the log.

When I open the page I do see the error... enter image description here

However, somehow the generated log status is always success and I don't get the signal that something went wrong. It's not make sense.

enter image description here

When I open the log I do see the exception thrown. enter image description here

Please advise. Thanks.

11
  • Did you use a try-catch block? You'll only see the exception at the top level if you fail to catch it.
    – sfdcfox
    Feb 28, 2016 at 1:04
  • It would be great to see a snippet of the code, you can remove any sensitive bits, but as sfdcfox mentions, try-catch blocks or other defensive coding techniques could be inherently blocking a failure. Feb 28, 2016 at 2:59
  • I too have observed this pattern with uncaught errors in Visualforce.
    – Adrian Larson
    Feb 28, 2016 at 3:19
  • 1
    I've seen this as well with Visualforce - twitter.com/FishOfPrey/status/697949945165295616. Execution stopped on an exception, but the developer console log has the Success Status. Feb 28, 2016 at 7:21
  • 2
    @DanielBallinger It's always done that. I'm actually kind of surprised that this question is not a duplicate, as far as I can tell.
    – sfdcfox
    Feb 28, 2016 at 7:50

2 Answers 2

4

Visualforce always shows successful during logging. I suspect that's because the underlying Visualforce layer catches the exception and renders it into something useful (if not a bit obnoxious, since it also wipes out the view state for the user). This behavior is not new to Winter '16, but has been around for quite a while (as far back as I can recall).

In fact, I think I plan on bringing this up as a bug with R & D, if I can get it that far, because it really does make the Status field less useful than it should be, and makes it especially hard to track down failures when you're trying to debug remotely and you've got hundreds of logs from users that all show successful when some of them really are not (and are the only ones you happen to care about).

Just a couple of weeks ago I had an error on a Visualforce page that was very chattery (about three or four logs per single transaction to work around limitations), and so I had to dig through about 2 or three pages of logs by opening them one at a time until I found the one that I wanted. It's a very terrible experience and can make tracking down errors a lot more challenging than it should be.

2
  • Yes. This is what I also feel. Thanks a lot @sfdcfox.
    – sfdcdev
    Feb 28, 2016 at 8:56
  • I've raised this as support case 13205328. Will see if Salesforce are willing to clean it up. Feb 29, 2016 at 1:12
6

Resolved in Summer '16 - View Visualforce Controller Exceptions in Debug Logs


I raised this with Salesforce support in Case 13205328.

They came back with the known issue Exception Details not logged in Debug Logs if happens in Constructor context.

This seemed to agree with my quick tests. If the exception occured in the constructor the Status showed success. The same exception from a property in the controller showed as Status "Divide by 0".

3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .