On Wednesday, 1 July 2020 at 17:44:45 UTC, Dennis wrote:
On assertion failure, the default error handler prints a stack trace that looks like this


My cgi.d does something just like that. It just does `exception.toString()` then `splitLines` on that string.



        Element exceptionToElement(Throwable t) {
                auto div = Element.make("div");
                div.addClass("exception-display");

                div.addChild("p", t.msg);
div.addChild("p", "Inner code origin: " ~ typeid(t).name ~ "@" ~ t.file ~ ":" ~ to!string(t.line));

                auto pre = div.addChild("pre");
                string s;
                s = t.toString();
                Element currentBox;
                bool on = false;
                foreach(line; s.splitLines) {
                        if(!on && line.startsWith("-----"))
                                on = true;
                        if(!on) continue;
                        if(line.indexOf("arsd/") != -1) {
                                if(currentBox is null) {
currentBox = pre.addChild("details"); currentBox.addChild("summary", "Framework code");
                                }
currentBox.addChild("span", line ~ "\n");
                        } else {
                                pre.addChild("span", line ~ "\n");
                                currentBox = null;
                        }
                }

                return div;
        }



Reply via email to