|
1 | 1 | # RelevanceStacktrace.jl |
2 | | -Julia relevance Stacktrace. |
| 2 | +**Find the error as fast as possible!** |
3 | 3 |
|
4 | | -# Goal |
5 | | -What are you searching during development? |
6 | | -99% of the time for the **TOP error of the stacktrace from your project's files**. >> **So it highlights it! :)** |
7 | | -1% you can use the unhighlighted parts. :) |
| 4 | +Most important elements in the stacktrace: |
| 5 | +1. error **source file that you edit** |
| 6 | + 1. **file + filename + line number** |
| 7 | + 2. function name |
| 8 | + 3. stack depth counter |
| 9 | + 4. modul name |
| 10 | +2. other project files |
| 11 | +3. other internal files |
| 12 | + |
| 13 | +So let's design it like this! -> RelevanceStacktrace |
8 | 14 |
|
9 | 15 | # Why |
10 | | -Julia stacktrace is for finding error. Why don't we use it to help us right? ;) |
11 | 16 |
|
12 | | -# Usage |
13 | | -Many way... but easiest: |
| 17 | +**Stacktrace is for locating the error. Let's FOCUS ONLY on that.** |
| 18 | + |
| 19 | +With this package in the past years I literally forgot what does searching for error is as I just click on the **BOLD GREEN** filename with a ctrl + click in vscode each time. |
| 20 | + |
| 21 | +**Green!** Because locating the error is a good thing. Not bad! So "Julia locate the right file and highlight it for us! ;) " |
| 22 | + |
| 23 | +I think 99% of the time the error will be in the **the first error of the stacktrace from your project's files**. >> **So it highlights it! :)** |
14 | 24 |
|
15 | | -`include(path_to_file * "RelevanceStacktrace.jl/src/RelevanceStacktrace.jl")` |
| 25 | +Any other time you will always have the unhighlighted parts. :) |
16 | 26 |
|
17 | | -or terminal |
| 27 | +# Demo |
| 28 | +Artificial error, to see it's power: |
| 29 | +``` |
| 30 | +using RelevanceStacktrace |
| 31 | +func4(x) = begin |
| 32 | + x+=x |
| 33 | + x=sum(x) .* [5, 3] |
| 34 | + x=sum(x[3]) |
| 35 | + return x/3 |
| 36 | +end |
| 37 | +func3(x) = x+5 + func4(x) |
| 38 | +func2(x) = x+3 + func3(x) |
| 39 | +func1(x) = begin |
| 40 | + func2(x) |
| 41 | +end |
| 42 | +func1(3) |
| 43 | +``` |
| 44 | + |
| 45 | +In real life example it is even more useful. |
18 | 46 |
|
| 47 | +Long stacktrace error: |
| 48 | +``` |
| 49 | +sum([]) |
19 | 50 | ``` |
20 | | -julia |
| 51 | +_error.png) |
| 52 | +This is still nice I think, but to be honest RelevanceStacktrace shines better when the error is in some of your project file. |
| 53 | + |
| 54 | +# INSTALL |
| 55 | + |
| 56 | +Many way... but easiest: |
| 57 | + |
| 58 | +```julia |
21 | 59 | ] add https://github.com/Cvikli/RelevanceStacktrace.jl.git |
22 | | -then: using RelevanceStacktrace |
| 60 | +using RelevanceStacktrace |
23 | 61 | ``` |
24 | 62 |
|
25 | | -or from a folder next to the cloned repo you can try using this version |
| 63 | +or |
26 | 64 |
|
| 65 | +```julia |
| 66 | +include(path_to_file * "RelevanceStacktrace.jl/src/RelevanceStacktrace.jl") |
| 67 | +using .RelevanceStacktrace |
27 | 68 | ``` |
| 69 | + |
| 70 | +or from a folder next to the cloned repo you can try using this version |
| 71 | + |
| 72 | +```julia |
28 | 73 | push!(LOAD_PATH, "../RelevanceStacktrace.jl/"); Base.load_path() |
29 | 74 | using RelevanceStacktrace |
30 | 75 | ``` |
31 | | - |
32 | | -But for me it doesn't perform well in certain situation, which I didn't have time to figure out... It only loads the package for the second time in this case... |
| 76 | +or |
| 77 | +``` |
| 78 | +using Pkg; Pkg.add(url="https://github.com/Cvikli/RelevanceStacktrace.jl.git") |
| 79 | +using RelevanceStacktrace |
| 80 | +``` |
33 | 81 |
|
34 | 82 | # Fun fact |
35 | | -**Debug the Debug.** :D We catch the error in the error handling and do a very basic error printing mechanism, so we can debug the backtrace printing error. |
36 | | -We overloaded the Base.print_stackframe... so basically any stackprinting will be changed with this method. :) |
| 83 | + |
| 84 | +**Debug the Debug.** :D We catch the error in the error handling and do a very basic error printing mechanism, so we can debug the backtrace printing error. |
37 | 85 |
|
38 | 86 | **The relevant errors are green, because finding one is a good thing!** ;) |
39 | 87 |
|
| 88 | +**Fallback to raw stacktrace printing.** As the project is sort of experimental, if a special case happen that we just don't bother to handle, it will fall back to print it in a basic format. |
| 89 | + |
| 90 | +# Future works? |
| 91 | +**Module names are useless.** Actually we could drop the modul names as it just waste of space |
| 92 | + |
| 93 | +**Function param types are pretty useless.** Maybe we could just show function names and parameters::types if it is actually matters... (As it is used very very rarely!) |
| 94 | + |
| 95 | +**AbbreviatedStackTraces sounds interesting** We could merge it into this project with an optional flag maybe later on? |
| 96 | + |
| 97 | +# Great stacktraces |
| 98 | +- AbbreviatedStackTraces: great project. :) https://github.com/BioTurboNick/AbbreviatedStackTraces.jl As UX decision I didn't merged it as the variation of stacktrace can create interruption in the thinking. We expect the output to be always the same. But of course more test should be done if someone believe it can be useful. |
| 99 | +- ClearStacktrace: was great for inspiration! https://github.com/jkrumbiegel/ClearStacktrace.jl |
| 100 | + |
40 | 101 | # Note |
41 | | -(**only tested on Ubuntu for Julia 1.6!** ) |
| 102 | + |
| 103 | +(**only tested on Ubuntu for Julia 1.8!** ) |
| 104 | + |
| 105 | +(**later version was tested on Ubuntu for Julia 1.6 and 1.7!** ) |
0 commit comments