Skip to content

Adding context information when requesting invalid column type #7013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 4.4.x
Choose a base branch
from

Conversation

mamazu
Copy link

@mamazu mamazu commented Jul 1, 2025

Q A
Type feature
Fixed issues closes #7012

Summary

Adding a way to set context on the UnkownColumnType. However in the place where I've added it there is no easy way to also get the name of the column, so I'm just providing the table, which should also already help.

@mamazu mamazu force-pushed the better_error_messages branch from ed91f05 to 6c06126 Compare July 1, 2025 15:49
try {
$column = $this->_getPortableTableColumnDefinition($tableColumn);
} catch (UnknownColumnType $unknownTypeException) {
throw UnknownColumnType::withContext($unknownTypeException->getType(), sprintf('table %s', $table));
Copy link
Member

@morozov morozov Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is overcomplication. Instead, we could try reusing UnsupportedTableDefinition and adding another static constructor (e.g. fromIntrospectionException(). It would accept the table name and reference the exception caught from _getPortableTableColumnDefinition() as the previous exception.

This way, we will be able to supply any introspection exception with the context (table name) w/o introducing new classes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a reasonable idea but what is this UnsupportedTableDefinition class? I can't find it in the source code or the dependencies.

Copy link
Member

@morozov morozov Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion. This class is available only in 5.0.x (introduced in #6853).

Please feel free to re-introduce it in your PR (w/o the methods that exist in 5.0.x, only with yours).

Note that the 4.2.x branch accepts only bug fixes. An improvement like this needs to be targeted at 4.3.x.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm thinking about this, this change might be better suited for 5.0 anyway then seeing that using a different exception would also change the type of exception thrown in the method. However, I think it still would be cool to have it in 4.3.x without any bc breaks.

How do other parts of the application handle those kinds of things. Like adding context to an exception sounds like a common enough use-case.

@mamazu mamazu changed the base branch from 4.2.x to 4.3.x July 5, 2025 09:47
@mamazu mamazu force-pushed the better_error_messages branch from 6c06126 to 4a10788 Compare July 5, 2025 09:51
@greg0ire greg0ire changed the base branch from 4.3.x to 4.4.x July 10, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show column name when column type is broken
2 participants