Feature #14140 ยป color.patch
| eval_error.c | ||
|---|---|---|
|
}
|
||
|
static void
|
||
|
print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg)
|
||
|
print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, int colored)
|
||
|
{
|
||
|
static const char underline[] = "\033[4;1m";
|
||
|
static const char bold[] = "\033[1m";
|
||
|
static const char reset[] = "\033[m";
|
||
|
const char *einfo = "";
|
||
|
long elen = 0;
|
||
|
VALUE mesg;
|
||
| ... | ... | |
|
warn_print_str(mesg);
|
||
|
warn_print(": ");
|
||
|
}
|
||
|
if (colored) {
|
||
|
warn_print(bold);
|
||
|
}
|
||
|
if (!NIL_P(emesg)) {
|
||
|
einfo = RSTRING_PTR(emesg);
|
||
| ... | ... | |
|
}
|
||
|
if (eclass == rb_eRuntimeError && elen == 0) {
|
||
|
if (colored) {
|
||
|
warn_print(underline);
|
||
|
}
|
||
|
warn_print("unhandled exception\n");
|
||
|
}
|
||
|
else {
|
||
| ... | ... | |
|
epath = rb_class_name(eclass);
|
||
|
if (elen == 0) {
|
||
|
if (colored) warn_print(underline);
|
||
|
warn_print_str(epath);
|
||
|
warn_print("\n");
|
||
|
}
|
||
| ... | ... | |
|
warn_print_str(tail ? rb_str_subseq(emesg, 0, len) : emesg);
|
||
|
if (epath) {
|
||
|
warn_print(" (");
|
||
|
if (colored) warn_print(underline);
|
||
|
warn_print_str(epath);
|
||
|
if (colored) warn_print(reset);
|
||
|
if (colored) warn_print(bold);
|
||
|
warn_print(")\n");
|
||
|
}
|
||
|
if (tail) {
|
||
| ... | ... | |
|
if (tail ? einfo[elen-1] != '\n' : !epath) warn_print2("\n", 1);
|
||
|
}
|
||
|
}
|
||
|
if (colored) warn_print(reset);
|
||
|
}
|
||
|
static void
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
if (rb_stderr_tty_p()) {
|
||
|
warn_print("Traceback (most recent call last):\n");
|
||
|
warn_print("\033[1mTraceback \033[m(most recent call last):\n");
|
||
|
print_backtrace(eclass, errat, TRUE);
|
||
|
print_errinfo(eclass, errat, emesg);
|
||
|
print_errinfo(eclass, errat, emesg, TRUE);
|
||
|
}
|
||
|
else {
|
||
|
print_errinfo(eclass, errat, emesg);
|
||
|
print_errinfo(eclass, errat, emesg, FALSE);
|
||
|
print_backtrace(eclass, errat, FALSE);
|
||
|
}
|
||
|
error:
|
||