1#include "backtrace.hpp"
2
3namespace Sass {
4
5 const sass::string traces_to_string(Backtraces traces, sass::string indent) {
6
7 sass::ostream ss;
8 sass::string cwd(File::get_cwd());
9
10 bool first = true;
11 size_t i_beg = traces.size() - 1;
12 size_t i_end = sass::string::npos;
13 for (size_t i = i_beg; i != i_end; i --) {
14
15 const Backtrace& trace = traces[i];
16
17 // make path relative to the current directory
18 sass::string rel_path(File::abs2rel(path: trace.pstate.getPath(), base: cwd, cwd));
19
20 // skip functions on error cases (unsure why ruby sass does this)
21 // if (trace.caller.substr(0, 6) == ", in f") continue;
22
23 if (first) {
24 ss << indent;
25 ss << "on line ";
26 ss << trace.pstate.getLine();
27 ss << ":";
28 ss << trace.pstate.getColumn();
29 ss << " of " << rel_path;
30 // ss << trace.caller;
31 first = false;
32 } else {
33 ss << trace.caller;
34 ss << std::endl;
35 ss << indent;
36 ss << "from line ";
37 ss << trace.pstate.getLine();
38 ss << ":";
39 ss << trace.pstate.getColumn();
40 ss << " of " << rel_path;
41 }
42
43 }
44
45 ss << std::endl;
46 return ss.str();
47
48 }
49
50};
51

source code of gtk/subprojects/libsass/src/backtrace.cpp