mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 13:40:11 +03:00
fix support for file/line
This commit is contained in:
parent
4b405b1432
commit
a8ed90f6e1
2 changed files with 31 additions and 2 deletions
|
@ -241,7 +241,7 @@ extern (C) int main(int argc, char **argv)
|
||||||
if (e.file)
|
if (e.file)
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg);
|
// fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg);
|
||||||
console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.toString)("\n");
|
console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.msg)("\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1064,6 +1064,7 @@ class Exception : Object
|
||||||
size_t line;
|
size_t line;
|
||||||
TraceInfo info;
|
TraceInfo info;
|
||||||
Exception next;
|
Exception next;
|
||||||
|
char[] buffer;
|
||||||
|
|
||||||
this( string msg, Exception next = null )
|
this( string msg, Exception next = null )
|
||||||
{
|
{
|
||||||
|
@ -1082,7 +1083,35 @@ class Exception : Object
|
||||||
|
|
||||||
override string toString()
|
override string toString()
|
||||||
{
|
{
|
||||||
return msg;
|
if (file.length == 0 && line == 0)
|
||||||
|
return msg;
|
||||||
|
if (buffer.length == 0)
|
||||||
|
{
|
||||||
|
// Write into buffer[] the following: "file(line): msg"
|
||||||
|
buffer.length = 4 + file.length + line.sizeof * 3 + msg.length;
|
||||||
|
auto i = file.length;
|
||||||
|
buffer[0 .. i] = file[];
|
||||||
|
buffer[i] = '(';
|
||||||
|
i++;
|
||||||
|
|
||||||
|
auto n = line;
|
||||||
|
auto j = i;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
buffer[i] = cast(char)((n % 10) + '0');
|
||||||
|
n /= 10;
|
||||||
|
i++;
|
||||||
|
} while (n);
|
||||||
|
buffer[j .. i].reverse;
|
||||||
|
buffer[i..i+3] = "): "[];
|
||||||
|
i += 3;
|
||||||
|
|
||||||
|
buffer[i .. i + msg.length] = msg[];
|
||||||
|
i += msg.length;
|
||||||
|
|
||||||
|
buffer = buffer[0 .. i];
|
||||||
|
}
|
||||||
|
return cast(invariant)buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue