From 4faecda2474ddcd3aacb17876fe0c1d948765244 Mon Sep 17 00:00:00 2001 From: Alexander Sklar Date: Wed, 29 Apr 2020 03:27:21 -0700 Subject: [PATCH 1/2] Expose Debug macro for hresult_error. Start catching these... --- vnext/ReactUWP/Views/Image/ReactImage.cpp | 5 ++++- vnext/include/ReactWindowsCore/cdebug.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/vnext/ReactUWP/Views/Image/ReactImage.cpp b/vnext/ReactUWP/Views/Image/ReactImage.cpp index b8ac25c6780..791a3776ecc 100644 --- a/vnext/ReactUWP/Views/Image/ReactImage.cpp +++ b/vnext/ReactUWP/Views/Image/ReactImage.cpp @@ -10,6 +10,7 @@ #include #include "Unicode.h" +#include "cdebug.h" namespace winrt { using namespace Windows::Foundation; @@ -84,6 +85,7 @@ winrt::Stretch ReactImage::ResizeModeToStretch(react::uwp::ResizeMode value) { default: // ResizeMode::Center // This function should never be called for the 'repeat' resizeMode case. // That is handled by the shouldUseCompositionBrush/switchBrushes code path. + // #4691 assert(value != ResizeMode::Repeat); if (m_imageSource.height < ActualHeight() && m_imageSource.width < ActualWidth()) { @@ -328,7 +330,8 @@ winrt::IAsyncOperation GetImageStreamAsync(Re co_return memoryStream; } - } catch (winrt::hresult_error const &) { + } catch (winrt::hresult_error const &e) { + DEBUG_HRESULT_ERROR(e); } co_return nullptr; diff --git a/vnext/include/ReactWindowsCore/cdebug.h b/vnext/include/ReactWindowsCore/cdebug.h index 942db2420d8..6e5e861d5dc 100644 --- a/vnext/include/ReactWindowsCore/cdebug.h +++ b/vnext/include/ReactWindowsCore/cdebug.h @@ -35,3 +35,8 @@ class basic_dostream : public std::basic_ostream { extern basic_dostream cdebug; extern basic_dostream cwdebug; + +#define DEBUG_HRESULT_ERROR(e) \ + cdebug << __FILE__ << " (" << __LINE__ << ") "; \ + cdebug.flush(); \ + cwdebug << e.message().c_str() << std::endl; From 54c1b04371f6bb4c5be162684c1071b783f8f60b Mon Sep 17 00:00:00 2001 From: Alexander Sklar Date: Wed, 29 Apr 2020 03:28:07 -0700 Subject: [PATCH 2/2] Change files --- ...-native-windows-2020-04-29-03-28-07-debug_hresult.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 change/react-native-windows-2020-04-29-03-28-07-debug_hresult.json diff --git a/change/react-native-windows-2020-04-29-03-28-07-debug_hresult.json b/change/react-native-windows-2020-04-29-03-28-07-debug_hresult.json new file mode 100644 index 00000000000..447fddf6bc8 --- /dev/null +++ b/change/react-native-windows-2020-04-29-03-28-07-debug_hresult.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Expose Debug macro for hresult_error. Start catching these...", + "packageName": "react-native-windows", + "email": "asklar@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-04-29T10:28:07.247Z" +}