From 9c6b4d50b83886b828d4bf167cc0da4e5aa7cc4e Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 19 Jun 2023 06:49:18 +0800 Subject: [PATCH] Improve error message when a platform doesn't support a widget. --- android/src/toga_android/factory.py | 4 ++++ changes/1992.feature.rst | 1 + cocoa/src/toga_cocoa/factory.py | 4 ++++ gtk/src/toga_gtk/factory.py | 4 ++++ iOS/src/toga_iOS/factory.py | 4 ++++ web/src/toga_web/factory.py | 4 ++++ winforms/src/toga_winforms/factory.py | 4 ++++ 7 files changed, 25 insertions(+) create mode 100644 changes/1992.feature.rst diff --git a/android/src/toga_android/factory.py b/android/src/toga_android/factory.py index 3f5d6fecce..fd664dd5f3 100644 --- a/android/src/toga_android/factory.py +++ b/android/src/toga_android/factory.py @@ -62,3 +62,7 @@ def not_implemented(feature): "Paths", "dialogs", ] + + +def __getattr__(name): # pragma: no cover + raise NotImplementedError(f"Toga's Android backend doesn't implement {name}") diff --git a/changes/1992.feature.rst b/changes/1992.feature.rst new file mode 100644 index 0000000000..803d761478 --- /dev/null +++ b/changes/1992.feature.rst @@ -0,0 +1 @@ +A more informative error message is returned when a platform backend doesn't support a widget. diff --git a/cocoa/src/toga_cocoa/factory.py b/cocoa/src/toga_cocoa/factory.py index c16e2ab0e6..cda6b628d1 100644 --- a/cocoa/src/toga_cocoa/factory.py +++ b/cocoa/src/toga_cocoa/factory.py @@ -77,3 +77,7 @@ def not_implemented(feature): "WebView", "Window", ] + + +def __getattr__(name): # pragma: no cover + raise NotImplementedError(f"Toga's Cocoa backend doesn't implement {name}") diff --git a/gtk/src/toga_gtk/factory.py b/gtk/src/toga_gtk/factory.py index ad4d0ce0a0..5e0694f300 100644 --- a/gtk/src/toga_gtk/factory.py +++ b/gtk/src/toga_gtk/factory.py @@ -73,3 +73,7 @@ def not_implemented(feature): "WebView", "Window", ] + + +def __getattr__(name): # pragma: no cover + raise NotImplementedError(f"Toga's GTK backend doesn't implement {name}") diff --git a/iOS/src/toga_iOS/factory.py b/iOS/src/toga_iOS/factory.py index 53278a1971..eba2cd9347 100644 --- a/iOS/src/toga_iOS/factory.py +++ b/iOS/src/toga_iOS/factory.py @@ -72,3 +72,7 @@ def not_implemented(feature): "WebView", "Window", ] + + +def __getattr__(name): # pragma: no cover + raise NotImplementedError(f"Toga's iOS backend doesn't implement {name}") diff --git a/web/src/toga_web/factory.py b/web/src/toga_web/factory.py index d563f14993..be253f674f 100644 --- a/web/src/toga_web/factory.py +++ b/web/src/toga_web/factory.py @@ -75,3 +75,7 @@ def not_implemented(feature): # 'WebView', # 'Window', ] + + +def __getattr__(name): # pragma: no cover + raise NotImplementedError(f"Toga's Web backend doesn't implement {name}") diff --git a/winforms/src/toga_winforms/factory.py b/winforms/src/toga_winforms/factory.py index 52eee11c08..b50675cd29 100644 --- a/winforms/src/toga_winforms/factory.py +++ b/winforms/src/toga_winforms/factory.py @@ -72,3 +72,7 @@ def not_implemented(feature): "WebView", "Window", ] + + +def __getattr__(name): # pragma: no cover + raise NotImplementedError(f"Toga's Winforms backend doesn't implement {name}")