Repository: litestar-org/litestar

Issue:
Bug: Handle dialect that doesn't support JSON type
### Description

I'm using a custom dialect that doesn't support JSON types. As you can see [here](https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/engine/create.py#L680), SQLAlchemy throws a `TypeError` when it receives invalid arguments on `create_engine`.

Litestar anticipates this error can happen, but it handles the wrong exception type (`ValueError` instead of `TypeError`).

https://github.com/litestar-org/litestar/blob/9f98636d8a2d3c22ce260b37a1543eee9e74bbc8/litestar/contrib/sqlalchemy/plugins/init/config/common.py#L187-L193

### URL to code causing the issue

_No response_

### MCVE

```python
# Your MCVE code here
```


### Steps to reproduce

```bash
1. Install a dialect that doesn't support JSON
2. Setup the SQLAlchemy plugin to use that dialect 
3. Start the Litestar app
```


### Screenshots

_No response_

### Logs

```bash
Using Litestar app from env: 'app.main:app'
...
INFO:     Started server process [55936]
INFO:     Waiting for application startup.
ERROR:    Traceback (most recent call last):
  File "<dev>/.venv/lib/python3.11/site-packages/litestar/app.py", line 541, in lifespan
    await self._call_lifespan_hook(hook)
  File "<dev>/.venv/lib/python3.11/site-packages/litestar/app.py", line 514, in _call_lifespan_hook
    ret = hook(self) if inspect.signature(hook).parameters else hook()  # type: ignore
          ^^^^^^^^^^
  File "<dev>/.venv/lib/python3.11/site-packages/litestar/contrib/sqlalchemy/plugins/init/config/common.py", line 252, in update_app_state
    app.state.update(self.create_app_state_items())
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<dev>/.venv/lib/python3.11/site-packages/litestar/contrib/sqlalchemy/plugins/init/config/common.py", line 242, in create_app_state_items
    self.engine_app_state_key: self.create_engine(),
                               ^^^^^^^^^^^^^^^^^^^^
  File "<dev>/.venv/lib/python3.11/site-packages/litestar/contrib/sqlalchemy/plugins/init/config/common.py", line 188, in create_engine
    self.engine_instance = self.create_engine_callable(self.connection_string, **engine_config)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 2, in create_engine
  File "<dev>/.venv/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^
  File "<dev>/.venv/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 680, in create_engine
    raise TypeError(
TypeError: Invalid argument(s) 'json_deserializer','json_serializer' sent to create_engine(), using configuration BigQueryDialect/QueuePool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.
```


### Litestar Version

2.0.0rc1

### Platform

- [X] Linux
- [ ] Mac
- [ ] Windows
- [ ] Other (Please specify in the description above)

<!-- POLAR PLEDGE BADGE START -->
---

## Funding
* If you would like to see an issue prioritized, make a pledge towards it!
* We receive the pledge once the issue is completed & verified

<a href="https://polar.sh/litestar-org/litestar/issues/2137">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/litestar-org/litestar/issues/2137/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/litestar-org/litestar/issues/2137/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->



Discussion:
What DB engine are you using here?

Resolving patch:
diff --git a/litestar/contrib/sqlalchemy/plugins/init/config/common.py b/litestar/contrib/sqlalchemy/plugins/init/config/common.py
--- a/litestar/contrib/sqlalchemy/plugins/init/config/common.py
+++ b/litestar/contrib/sqlalchemy/plugins/init/config/common.py
@@ -186,7 +186,7 @@ def create_engine(self) -> EngineT:
         engine_config = self.engine_config_dict
         try:
             self.engine_instance = self.create_engine_callable(self.connection_string, **engine_config)
-        except ValueError:
+        except TypeError:
             # likely due to a dialect that doesn't support json type
             del engine_config["json_deserializer"]
             del engine_config["json_serializer"]


Test patch:
diff --git a/tests/unit/test_contrib/test_sqlalchemy/test_init_plugin/test_common.py b/tests/unit/test_contrib/test_sqlalchemy/test_init_plugin/test_common.py
--- a/tests/unit/test_contrib/test_sqlalchemy/test_init_plugin/test_common.py
+++ b/tests/unit/test_contrib/test_sqlalchemy/test_init_plugin/test_common.py
@@ -66,7 +66,7 @@ def test_create_engine_if_no_engine_instance_or_connection_string_provided(
         config.create_engine()
 
 
-def test_call_create_engine_callable_value_error_handling(
+def test_call_create_engine_callable_type_error_handling(
     config_cls: type[SQLAlchemySyncConfig | SQLAlchemySyncConfig], monkeypatch: MonkeyPatch
 ) -> None:
     """If the dialect doesn't support JSON types, we get a ValueError.
@@ -78,7 +78,7 @@ def side_effect(*args: Any, **kwargs: Any) -> None:
         nonlocal call_count
         call_count += 1
         if call_count == 1:
-            raise ValueError()
+            raise TypeError()
 
     config = config_cls(connection_string="sqlite://")
     create_engine_callable_mock = MagicMock(side_effect=side_effect)