Modify the exception to make it more readable. Args: e: The exception to modify.
(e: Exception)
| 816 | |
| 817 | |
| 818 | def _modify_exception(e: Exception) -> None: |
| 819 | """Modify the exception to make it more readable. |
| 820 | |
| 821 | Args: |
| 822 | e: The exception to modify. |
| 823 | """ |
| 824 | if len(e.args) == 1 and isinstance((msg := e.args[0]), str): |
| 825 | while (state_index := msg.find("reflex___")) != -1: |
| 826 | dot_index = msg.find(".", state_index) |
| 827 | if dot_index == -1: |
| 828 | break |
| 829 | state_name = msg[state_index:dot_index] |
| 830 | module_dot_state_name = state_name.replace("___", ".").rsplit("__", 1)[-1] |
| 831 | module_path, _, state_snake_case = module_dot_state_name.rpartition(".") |
| 832 | if not state_snake_case: |
| 833 | break |
| 834 | actual_state_name = to_title_case(state_snake_case) |
| 835 | msg = ( |
| 836 | f"{msg[:state_index]}{module_path}.{actual_state_name}{msg[dot_index:]}" |
| 837 | ) |
| 838 | |
| 839 | msg = msg.replace(FIELD_MARKER, "") |
| 840 | |
| 841 | e.args = (msg,) |
| 842 | |
| 843 | |
| 844 | def into_component(component: Component | ComponentCallable) -> Component: |
no test coverage detected