mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 9.0.1576: users may not know what to do with an internal error
Problem: Users may not know what to do with an internal error. Solution: Add a translated message with instructions.
This commit is contained in:
@@ -592,12 +592,12 @@ ignore_error_for_testing(char_u *error)
|
||||
}
|
||||
|
||||
static int
|
||||
ignore_error(char_u *msg)
|
||||
ignore_error(const char *msg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ignore_error_list.ga_len; ++i)
|
||||
if (strstr((char *)msg,
|
||||
if (strstr(msg,
|
||||
(char *)((char_u **)(ignore_error_list.ga_data))[i]) != NULL)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
@@ -629,7 +629,7 @@ do_perror(char *msg)
|
||||
* Note: caller must check 'emsg_not_now()' before calling this.
|
||||
*/
|
||||
static int
|
||||
emsg_core(char_u *s)
|
||||
emsg_core(const char *s)
|
||||
{
|
||||
int attr;
|
||||
char_u *p;
|
||||
@@ -665,7 +665,7 @@ emsg_core(char_u *s)
|
||||
* when the message should be ignored completely (used for the
|
||||
* interrupt message).
|
||||
*/
|
||||
if (cause_errthrow(s, severe, &ignore) == TRUE)
|
||||
if (cause_errthrow((char_u *)s, severe, &ignore) == TRUE)
|
||||
{
|
||||
if (!ignore)
|
||||
++did_emsg;
|
||||
@@ -674,7 +674,7 @@ emsg_core(char_u *s)
|
||||
|
||||
if (in_assert_fails && emsg_assert_fails_msg == NULL)
|
||||
{
|
||||
emsg_assert_fails_msg = vim_strsave(s);
|
||||
emsg_assert_fails_msg = vim_strsave((char_u *)s);
|
||||
emsg_assert_fails_lnum = SOURCING_LNUM;
|
||||
vim_free(emsg_assert_fails_context);
|
||||
emsg_assert_fails_context = vim_strsave(
|
||||
@@ -682,7 +682,7 @@ emsg_core(char_u *s)
|
||||
}
|
||||
|
||||
// set "v:errmsg", also when using ":silent! cmd"
|
||||
set_vim_var_string(VV_ERRMSG, s, -1);
|
||||
set_vim_var_string(VV_ERRMSG, (char_u *)s, -1);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -711,7 +711,7 @@ emsg_core(char_u *s)
|
||||
redir_write(p, -1);
|
||||
vim_free(p);
|
||||
}
|
||||
redir_write(s, -1);
|
||||
redir_write((char_u *)s, -1);
|
||||
}
|
||||
#ifdef FEAT_EVAL
|
||||
// Only increment did_emsg_def when :silent! wasn't used inside the
|
||||
@@ -720,7 +720,7 @@ emsg_core(char_u *s)
|
||||
++did_emsg_def;
|
||||
#endif
|
||||
#ifdef FEAT_EVAL
|
||||
ch_log(NULL, "ERROR silent: %s", (char *)s);
|
||||
ch_log(NULL, "ERROR silent: %s", s);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
@@ -778,45 +778,44 @@ emsg_core(char_u *s)
|
||||
}
|
||||
|
||||
/*
|
||||
* Print an error message.
|
||||
* Print error message "s". Should already be translated.
|
||||
* Return TRUE if wait_return() not called.
|
||||
*/
|
||||
int
|
||||
emsg(char *s)
|
||||
{
|
||||
// Skip this if not giving error messages at the moment.
|
||||
if (!emsg_not_now())
|
||||
return emsg_core((char_u *)s);
|
||||
return TRUE; // no error messages at the moment
|
||||
if (emsg_not_now())
|
||||
return TRUE;
|
||||
|
||||
return emsg_core(s);
|
||||
}
|
||||
|
||||
#ifndef PROTO // manual proto with __attribute__
|
||||
/*
|
||||
* Print an error message with format string and variable arguments.
|
||||
* Note: caller must not pass 'IObuff' as 1st argument.
|
||||
* Print error message "s" with format string and variable arguments.
|
||||
* "s" should already be translated.
|
||||
* Note: caller must not use "IObuff" for "s"!
|
||||
* Return TRUE if wait_return() not called.
|
||||
*/
|
||||
int
|
||||
semsg(const char *s, ...)
|
||||
{
|
||||
// Skip this if not giving error messages at the moment.
|
||||
if (!emsg_not_now())
|
||||
{
|
||||
if (IObuff == NULL)
|
||||
{
|
||||
// Very early in initialisation and already something wrong, just
|
||||
// give the raw message so the user at least gets a hint.
|
||||
return emsg_core((char_u *)s);
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list ap;
|
||||
if (emsg_not_now())
|
||||
return TRUE;
|
||||
|
||||
va_start(ap, s);
|
||||
vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
|
||||
va_end(ap);
|
||||
return emsg_core(IObuff);
|
||||
}
|
||||
}
|
||||
return TRUE; // no error messages at the moment
|
||||
if (IObuff == NULL)
|
||||
// Very early in initialisation and already something wrong, just
|
||||
// give the raw message so the user at least gets a hint.
|
||||
return emsg_core(s);
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, s);
|
||||
vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
|
||||
va_end(ap);
|
||||
return emsg_core((char *)IObuff);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -831,7 +830,11 @@ iemsg(char *s)
|
||||
if (emsg_not_now())
|
||||
return;
|
||||
|
||||
emsg_core((char_u *)s);
|
||||
// Give a generic error which is translated. The error itself may not be
|
||||
// translated, it almost never shows.
|
||||
emsg_core(_(e_internal_error_please_report_a_bug));
|
||||
|
||||
emsg_core(s);
|
||||
#if defined(ABORT_ON_INTERNAL_ERROR) && defined(FEAT_EVAL)
|
||||
set_vim_var_string(VV_ERRMSG, (char_u *)s, -1);
|
||||
msg_putchar('\n'); // avoid overwriting the error message
|
||||
@@ -853,11 +856,15 @@ siemsg(const char *s, ...)
|
||||
if (emsg_not_now())
|
||||
return;
|
||||
|
||||
// Give a generic error which is translated. The error itself may not be
|
||||
// translated, it almost never shows.
|
||||
emsg_core(_(e_internal_error_please_report_a_bug));
|
||||
|
||||
if (IObuff == NULL)
|
||||
{
|
||||
// Very early in initialisation and already something wrong, just
|
||||
// give the raw message so the user at least gets a hint.
|
||||
emsg_core((char_u *)s);
|
||||
emsg_core(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -866,7 +873,7 @@ siemsg(const char *s, ...)
|
||||
va_start(ap, s);
|
||||
vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
|
||||
va_end(ap);
|
||||
emsg_core(IObuff);
|
||||
emsg_core((char *)IObuff);
|
||||
}
|
||||
# ifdef ABORT_ON_INTERNAL_ERROR
|
||||
msg_putchar('\n'); // avoid overwriting the error message
|
||||
@@ -882,6 +889,10 @@ siemsg(const char *s, ...)
|
||||
void
|
||||
internal_error(char *where)
|
||||
{
|
||||
// Give a generic error which is translated. The error itself may not be
|
||||
// translated, it almost never shows.
|
||||
emsg_core(_(e_internal_error_please_report_a_bug));
|
||||
|
||||
siemsg(_(e_internal_error_str), where);
|
||||
}
|
||||
|
||||
@@ -893,7 +904,11 @@ internal_error(char *where)
|
||||
void
|
||||
internal_error_no_abort(char *where)
|
||||
{
|
||||
semsg(_(e_internal_error_str), where);
|
||||
// Give a generic error which is translated. The error itself may not be
|
||||
// translated, it almost never shows.
|
||||
emsg_core(_(e_internal_error_please_report_a_bug));
|
||||
|
||||
semsg(_(e_internal_error_str), where);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user