-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the readability of stack traces #1458
Comments
Some examples of panic outputs in different environments for inspiration are below. They use very simple inputs, so their utility may be limited, but maybe we can learn something from them. I also understand that the diagnostic events are not stack traces, and they don't point to code, but developers sort of treat them as similar, as a way to understand where the program was when something went wrong. Rustfn main() {
f1(1)
}
fn f1(i: u32) {
f2()
}
fn f2() {
f3()
}
fn f3() {
panic!("oh no")
}
Gopackage main
func main() {
f1(1)
}
func f1(i int) {
f2()
}
func f2() {
f3()
}
func f3() {
panic("oh no")
}
Nodefunction f1(i) {
f2();
}
function f2() {
f3();
}
function f3() {
throw "oh no";
}
f1(1);
Bunfunction f1(i) {
f2();
}
function f2() {
f3();
}
function f3() {
throw "oh no";
}
f1(1);
Denofunction f1(i: u32) {
f2();
}
function f2() {
f3();
}
function f3() {
throw "oh no";
}
f1(1);
Pythondef f1(i):
f2()
def f2():
f3()
def f3():
raise Exception("oh no")
f1(1)
Rubydef f1(i)
f2()
end
def f2()
f3()
end
def f3()
raise "oh no"
end
f1(1)
Javapublic class Main {
public static void main(String[] args) {
f1(1);
}
public static void f1(int i) {
f2();
}
public static void f2() {
f3();
}
public static void f3() {
throw new RuntimeException("oh no");
}
}
.NETusing System;
public class Program
{
public static void Main()
{
f1(1);
}
public static void f1(int i) {
f2();
}
public static void f2() {
f3();
}
public static void f3() {
throw new Exception("oh no");
}
}
Swiftimport Foundation
func f1(i: Int) {
f2();
}
func f2() {
f3();
}
func f3() {
fatalError("oh no");
}
f1(i: 1);
Zigpub fn main() !void {
f1(1);
}
fn f1(_: i32) void {
f2();
}
fn f2() void {
f3();
}
fn f3() void {
@panic("oh no");
}
|
My main interest is mostly just readability. So adding more whitespace and line breaks would go a long way towards legibility. e.g. Event log (newest first):
0: [Diagnostic Event]
topics:[error, Error(Auth, InvalidAction)],
data:"escalating error to panic"
1: [Diagnostic Event]
topics:[error, Error(Auth, InvalidAction)],
data:["contract call failed", add, [[Policy, [CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4], [Temporary], [Admin]]]]
2: [Failed Diagnostic Event (not emitted)]
contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM,
topics:[error, Error(Auth, InvalidAction)], data:"caught error from function"
3: [Failed Diagnostic Event (not emitted)]
contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM,
topics:[error, Error(Auth, InvalidAction)],
data:"escalating error to panic"
4: [Failed Diagnostic Event (not emitted)]
contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM,
topics:[error, Error(Auth, InvalidAction)],
data:["Unauthorized function call for address", CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM]
5: [Diagnostic Event]
topics:[fn_call, Bytes(0000000000000000000000000000000000000000000000000000000000000001), add],
data:[Policy, [CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4], [Temporary], [Admin]]
6: [Diagnostic Event]
contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM,
topics:[fn_return, add],
data:Void
7: [Contract Event]
contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM,
topics:[sw_v1, add, [Ed25519, [Bytes(a1738d72617d88f775693c9b9033d8bbb99d127ea9ac0f04940dd090350c5b4e)]]],
data:[Ed25519, [Admin]]
8: [Diagnostic Event]
topics:[fn_call, Bytes(0000000000000000000000000000000000000000000000000000000000000001), add],
data:[Ed25519, [Bytes(a1738d72617d88f775693c9b9033d8bbb99d127ea9ac0f04940dd090350c5b4e)], [Persistent], [Admin]]
9: [Diagnostic Event]
contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM,
topics:[fn_return, add],
data:Void
10: [Contract Event]
contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM,
topics:[sw_v1, add, [Secp256r1, [Bytes(f3f8d84ae2da5566c4a70e977c2a49888a66bb8c)]]],
data:[Secp256r1, [Bytes(04a38ef5f2713768bd3480eeceaec2b10464a1f3b1ff0a3539c2cd2dd00a83a75d2c7b7e5fdbcfe6af5a602979c57fb44aeca0003cb9d3ae85d7c8d0e633d25ed6)], [Admin]]
11: [Diagnostic Event]
topics:[fn_call, Bytes(0000000000000000000000000000000000000000000000000000000000000001), add],
data:[Secp256r1, [Bytes(f3f8d84ae2da5566c4a70e977c2a49888a66bb8c)], [Bytes(04a38ef5f2713768bd3480eeceaec2b10464a1f3b1ff0a3539c2cd2dd00a83a75d2c7b7e5fdbcfe6af5a602979c57fb44aeca0003cb9d3ae85d7c8d0e633d25ed6)], [Persistent], [Admin]] You could further break up arrays by comma if you wanted to but that would start to make stack traces very very long. |
Idk if we have the ability to color anything but highlighting actual error messages would also be really nice. e.g. from above these are really the meat of the error |
I think we should improve the readability of the diagnostic event and stack trace outputs that the environment generates on the console and in tests when there are failures.
This is not about improving the contents / data within the diagnostic events, and only the presentation of the existing data, so it is easier to glance and digest.
An example of the existing output as of
v21.2.1
:The text was updated successfully, but these errors were encountered: