I have just added workaround of this bug in by code. And now it is working and returns backtrace

string[] getBacktrace(Throwable ex)
{
        import std.conv: to;
        import core.exception: OutOfMemoryError;

        string[] backTrace;
        try {
                foreach( inf; ex.info )
                        backTrace ~= inf.to!string;
} catch( OutOfMemoryError exc ) {} // Workaround for some bug in DefaultTraceInfo.opApply
        return backTrace;
}

auto errorToJSON(Throwable ex)
{
        import std.json: JSONValue;

        return JSONValue([
                "code": JSONValue(1),
                "message": JSONValue(ex.msg),
                "data": JSONValue([
                        "file": JSONValue(ex.file),
                        "line": JSONValue(ex.line),
                        "backtrace": JSONValue(getBacktrace(ex))
                ])
        ]);
}

Reply via email to