SqlContentEntityStorage::wrapSchemaException() catches exceptions and rethrows them, losing all information about the cause. This makes it very difficult to figure out what the actual problem is.

Simple patch...

CommentFileSizeAuthor
better-wrapper.patch706 bytesjhodgdon

Comments

jhodgdon created an issue. See original summary.

jhodgdon’s picture

With this patch, a test failure I had gave me this message:

Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd8test.simpletest626768field_deleted_revision_e3b0c44298' doesn't exist: SELECT 1 AS expression FROM {field_deleted_revision_e3b0c44298} t WHERE ( (field_test_int_value IS NOT NULL ) ) LIMIT 1 OFFSET 0; Array ( ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1461 of ..../core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

instead of just

Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1459 of ..../core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

This was from the 2nd catch section. I haven't tested to see if an exception from the 1st catch section gives a helpful message, but it probably can't be worse than just throwing out the message from the previous exception, right?

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +rc target triage

If only exception messages could be classified as docs, this would be rc eligible :)

That said, I think it's worth getting this in. I've usually just worked around this by putting a breakpoint in wrapSchemaException(), but why force everyone to rely on a debugger?

xjm’s picture

Issue tags: -rc target triage +rc target

Discussed with the D8 committers and we agreed with making this an rc target.

xjm’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • xjm committed d6af6fc on 8.0.x
    Issue #2597548 by jhodgdon, tim.plunkett: Useless message thrown by...
berdir’s picture

We should really fix our exception handling to show wrapped/nested exceptions too, that would solve this in a better way. Any exception thrown while saving an entity has the exact same problem.

jhodgdon’s picture

I don't understand why we are doing catch/wrap strategies anyway really. ?!? It just masks the real problems.

Status: Fixed » Closed (fixed)

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