changeset 27706:847dece1ae10

Include error number in message if library loading fails (bug #57202). * oct-shlib.cc (octave_w32_shlib::octave_w32_shlib): Include error number in message if library loading fails in case the text should be too cryptic.
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 17 Nov 2019 11:39:57 +0100
parents 6c2a56c39c5d
children 377f069841c1
files liboctave/util/oct-shlib.cc
diffstat 1 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/oct-shlib.cc	Sat Nov 16 18:37:20 2019 -0800
+++ b/liboctave/util/oct-shlib.cc	Sun Nov 17 11:39:57 2019 +0100
@@ -316,20 +316,18 @@
                         MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
                         reinterpret_cast <wchar_t *> (&error_text), 0, nullptr);
 
-        std::string msg = "opening the library '" + m_file + "' failed: ";
+        std::ostringstream err_str;
+        err_str << "opening the library '" << m_file << "' failed (error "
+                << last_error << "): ";
         if (error_text != nullptr)
           {
-            msg.append (sys::u8_from_wstring (error_text));
+            err_str << sys::u8_from_wstring (error_text);
             LocalFree (error_text);
           }
         else
-          {
-            std::ostringstream err_str;
-            err_str << "Unknown error (" << last_error << ").";
-            msg.append (err_str.str ());
-          }
+          err_str << "Unknown error.";
 
-        (*current_liboctave_error_handler) ("%s", msg.c_str ());
+        (*current_liboctave_error_handler) ("%s", err_str.str ().c_str ());
       }
   }