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" +} 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;