The attached patch uses _drupal_decode_exception() to print the exception instead of just getMessage().

This is especially helpful for PDOExceptions, when you can see which db_* call actually triggered the exception also the query that triggered it.

This needs to be improved a bit more, since SimpleTest already displays the file and caller information, so we should override it with that instead of displaying that information twice, differently.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boombatower’s picture

Seems like a good idea.

Curious on the line/function/file display...won't the exception be raised in a different file (usually [or at least can]) then the assert or calling bit of code in the test file. Thus the funciton/line/file display by simpletest gives you the calling bit, and the line/file/function displayed by the assertion in the message text give you the bit of code that raised the assertion? If so then I think we should display both and your curren format seems fine.

boombatower’s picture

Status: Needs review » Reviewed & tested by the community

So I'm fine with it assume what I wrote in #1 is true.

moshe weitzman’s picture

Oh, this is very helpful. +1

Dries’s picture

Status: Reviewed & tested by the community » Needs review

Berdir wrote: This needs to be improved a bit more, since SimpleTest already displays the file and caller information, so we should override it with that instead of displaying that information twice, differently.

Before committing this patch, I'd like to better understand what needs to be improved. In generally, I agree that we should avoid duplicating this information. It is OK to make bigger changes to SimpleTest, if necessary. It is not really subject to the code freeze. Anyway, let's see what else is required here.

Berdir’s picture

FileSize
107.82 KB
39.69 KB

I don't think that there are bigger chances necessary here.

What I was trying to say is that simpletest displays the location where an exception was thrown. With my patch, that information is also displayed as part of the actual message. See attached screenshot.

The difference is however, that _drupal_decode_exception() contains special handling for PDO-Exception which displays the location where the query was actually executed and also displays the full query. This is really helpful, because some PDO-Exceptions are a) quite cryptic and b) you have no clue which query actually failed.

Now, imho, the only question is if we want to..
a) Keep it as it with the patch, see screenshot
b) Display the location only once.

I like a) more, because in some cases, you want to know where exactly the exception was thrown, for example, when there are bugs in DBTNG itself.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Nice screenies. I think it is pretty clear that 'with_patch' is superior.

On a related note, see #711108: Richer exception reporting for watchdog(). Perhaps berdir can lend a hand there. That deals with PDO exceptions outside of simpletest.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Clearly better! Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.