if (len == 0)
{
unsigned err = (unsigned) GetLastError ();
- error (_("Error getting executable filename (error %u): %s"),
- err, strwinerror (err));
+ throw_winerror_with_name (_("Error getting executable filename"), err);
}
if (cygwin_conv_path (CCP_WIN_W_TO_POSIX, pathbuf, exe_name_ret,
exe_name_max_len) < 0)
if (len == 0)
{
unsigned err = (unsigned) GetLastError ();
- error (_("Error getting executable filename (error %u): %s"),
- err, strwinerror (err));
+ throw_winerror_with_name (_("Error getting executable filename"), err);
}
#endif
});
if (err.has_value ())
- error (_("Failed to resume program execution"
- " (ContinueDebugEvent failed, error %u: %s)"),
- *err, strwinerror (*err));
+ throw_winerror_with_name (_("Failed to resume program execution"
+ " - ContinueDebugEvent failed"),
+ *err);
return TRUE;
}
else
{
unsigned err = (unsigned) GetLastError ();
- error (_("OpenProcess call failed, GetLastError = %u: %s"),
- err, strwinerror (err));
+ throw_winerror_with_name (_("OpenProcess call failed"), err);
/* We can not debug anything in that case. */
}
add_thread (ptid_t (windows_process.current_event.dwProcessId, 0,
});
if (err.has_value ())
- error (_("Can't attach to process %u (error %u: %s)"),
- (unsigned) pid, *err, strwinerror (*err));
+ {
+ std::string msg = string_printf (_("Can't attach to process %u"),
+ (unsigned) pid);
+ throw_winerror_with_name (msg.c_str (), *err);
+ }
DebugSetProcessKillOnExit (FALSE);
});
if (err.has_value ())
- error (_("Can't detach process %u (error %u: %s)"),
- (unsigned) windows_process.current_event.dwProcessId,
- *err, strwinerror (*err));
+ {
+ std::string msg
+ = string_printf (_("Can't detach process %u"),
+ (unsigned) windows_process.current_event.dwProcessId);
+ throw_winerror_with_name (msg.c_str (), *err);
+ }
target_announce_detach (from_tty);
#endif /* !__CYGWIN__ */
if (ret.has_value ())
- error (_("Error creating process %s, (error %u: %s)"),
- exec_file, *ret, strwinerror (*ret));
+ {
+ std::string msg = _("Error creating process ") + std::string (exec_file);
+ throw_winerror_with_name (msg.c_str (), *ret);
+ }
#ifdef __x86_64__
BOOL wow64;
if (!IsWow64Process (proch, &wow64))
{
DWORD err = GetLastError ();
- error ("Check if WOW64 process failed (error %d): %s\n",
- (int) err, strwinerror (err));
+ throw_winerror_with_name ("Check if WOW64 process failed", err);
}
windows_process.wow64_process = wow64;
if (!ret)
{
- error ("Error creating process \"%s %s\", (error %d): %s\n",
- program, args, (int) err, strwinerror (err));
+ std::string msg = string_printf (_("Error creating process \"%s %s\""),
+ program, args);
+ throw_winerror_with_name (msg.c_str (), err);
}
else
{
}
err = GetLastError ();
- error ("Attach to process failed (error %d): %s\n",
- (int) err, strwinerror (err));
+ throw_winerror_with_name ("Attach to process failed", err);
}
/* See nat/windows-nat.h. */
return buf;
}
+/* See errors.h. */
+
+void
+throw_winerror_with_name (const char *string, ULONGEST err)
+{
+ error (_("%s (error %d): %s"), string, err, strwinerror (err));
+}
+
#endif /* USE_WIN32API */
extern const char *strwinerror (ULONGEST error);
+/* Like perror_with_name, but for Windows errors. Throw an exception
+ including STRING and the system text for the given error
+ number. */
+
+extern void throw_winerror_with_name (const char *string, ULONGEST err)
+ ATTRIBUTE_NORETURN;
+
#endif /* USE_WIN32API */
#endif /* COMMON_ERRORS_H */