Skip to content

Improve diagnostics for missing source code file #6

@alexander-yevsyukov

Description

@alexander-yevsyukov

I accidentally use wrong path for a source code file with fences and got the following console output:

2026/02/16 18:04:03 INFO starting application, reading args...
panic: embedding error for file ``: unable to embed construction for doc file `../content/docs/validation/01-getting-started/first-model.md` at line 110: unable to read the code fence end: file /Users/sanders/Projects/Spine/validation/docs/_bin/build/fragments/first-model/src/test/kotlin/io/spine/validation/docs/firstmodel/BankCardKtTest-51ad477f.java doesn't exist.

goroutine 1 [running]:
embed-code/embed-code-go/embedding.EmbedAll({{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10494a6c0, 0x1, 0x1}, {0x10494bc40, 0x2, 0x2}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/embedding/processor.go:134 +0x178
embed-code/embed-code-go/cli.EmbedCodeSamples({{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10494a6c0, 0x1, 0x1}, {0x10494bc40, 0x2, 0x2}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/cli/cli.go:111 +0x70
main.main()
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/main.go:111 +0x48c

Here are the problems with this output.

Empty file name reference

Why don't we have anything between backticks in the piece below?

panic: embedding error for file ``:

Hash in the name of the file

The file name I wrongly used was BankCardKtTest.java. It should have been BankCardKtTest.kt. But why do we have 51ad477f in the below fragment:

BankCardKtTest-51ad477f.java doesn't exist.

Stacktrace is redundant for regular users

The below block has very limited value for regular users of the tool:

goroutine 1 [running]:
embed-code/embed-code-go/embedding.EmbedAll({{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10494a6c0, 0x1, 0x1}, {0x10494bc40, 0x2, 0x2}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/embedding/processor.go:134 +0x178
embed-code/embed-code-go/cli.EmbedCodeSamples({{0x1400000e810, 0x8}, {0x1400000e830, 0x10}, {0x10494a6c0, 0x1, 0x1}, {0x10494bc40, 0x2, 0x2}, ...})
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/cli/cli.go:111 +0x70
main.main()
        /Users/vladyslav.kuksiuk/Desktop/Work/embed-code/embed-code-go/main.go:111 +0x48c

It would be good to have stacktrace only when the utility is executed with the --stacktrace flag.

References to the developer's file system in stacktrace

Why do we have the path /Users/vladyslav.kuksiuk/Desktop/Work in stacktrace? Can we have the path to the GitHub instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions