log error with missing components # Description print errors at the cpp level so they are surfaced on our higher level runtimes # Details In order to provide users with more information about errors, we're relying on the fprintf method from cpp. This is a temporary solution until we build a more robust error message model. Diffs= 099d761edd log error with missing components (#9431) Co-authored-by: hernan <hernan@rive.app>
diff --git a/.rive_head b/.rive_head index 87c573a..b4e17f2 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -59d5d4d65889f834957aaac1351f7ab4c64af7cf +099d761edd24a57e98239b6615ff4f26665dbc4f
diff --git a/src/file.cpp b/src/file.cpp index afeca04..8593d5b 100644 --- a/src/file.cpp +++ b/src/file.cpp
@@ -868,6 +868,9 @@ { return createViewModelRuntime(m_ViewModels[index]); } + fprintf(stderr, + "Could not find View Model. Index %zu is out of range.\n", + index); return nullptr; } @@ -880,16 +883,25 @@ return createViewModelRuntime(viewModel); } } + fprintf(stderr, "Could not find View Model named %s.\n", name.c_str()); return nullptr; } ViewModelRuntime* File::defaultArtboardViewModel(Artboard* artboard) const { + if (artboard == nullptr) + { + fprintf(stderr, "Invalid Artboard\n"); + return nullptr; + } if ((size_t)artboard->viewModelId() < m_ViewModels.size()) { auto viewModel = m_ViewModels[artboard->viewModelId()]; return createViewModelRuntime(viewModel); } + fprintf(stderr, + "Could not find a View Model linked to Artboard %s.\n", + artboard->name().c_str()); return nullptr; }
diff --git a/src/viewmodel/runtime/viewmodel_runtime.cpp b/src/viewmodel/runtime/viewmodel_runtime.cpp index 24f4d4d..f99869d 100644 --- a/src/viewmodel/runtime/viewmodel_runtime.cpp +++ b/src/viewmodel/runtime/viewmodel_runtime.cpp
@@ -107,6 +107,13 @@ m_file->completeViewModelInstance(copy); return createRuntimeInstance(copy); } + else + { + fprintf( + stderr, + "Could not find View Model Instance. Index %zu is out of range.\n", + index); + } return nullptr; } @@ -121,6 +128,14 @@ m_file->completeViewModelInstance(copy); return createRuntimeInstance(copy); } + else + { + fprintf(stderr, + "Could not find View Model Instance named %s. Was it marked to " + "export " + "with the file?\n", + name.c_str()); + } return nullptr; } @@ -132,6 +147,8 @@ { return createRuntimeInstance(viewModelInstance); } + fprintf(stderr, + "Default instance not found. Creating empty instance instead.\n"); return createInstance(); }