-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
645b111
commit 37d13b3
Showing
7 changed files
with
50 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// Add a backtrace entry for a single element | ||
/// | ||
/// - ctx (Context): The current context | ||
/// - element (string): The elements type (e.g. circle) | ||
/// - name (none,string): The elements name | ||
/// -> context | ||
#let add-element-backtrace(ctx, element, name) = { | ||
let message = "element: " + element | ||
if name != none { | ||
message += ", name: " + name | ||
} | ||
|
||
ctx.backtrace.push(message) | ||
return ctx | ||
} | ||
|
||
#let _get-backtrace-string(ctx) = { | ||
if ctx != none and ctx.backtrace != () { | ||
return ". Backtrace: " + ctx.backtrace.rev().join("; ") | ||
} | ||
return "" | ||
} | ||
|
||
/// Panic but with cetz backtrace | ||
#let panic(ctx, message) = { | ||
std.panic(message + _get-backtrace-string(ctx)) | ||
} | ||
|
||
/// Assert but with cetz backtrace | ||
#let assert(ctx, cond, message: "") = { | ||
std.assert(cond, message: message + _get-backtrace-string(ctx)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters