Skip to content

Improve the display of missing files#15

Open
Vladyslav-Kuksiuk wants to merge 2 commits intomasterfrom
improve-file-log
Open

Improve the display of missing files#15
Vladyslav-Kuksiuk wants to merge 2 commits intomasterfrom
improve-file-log

Conversation

@Vladyslav-Kuksiuk
Copy link
Copy Markdown
Contributor

This PR improves displaying of paths, when file or fragment wasn't found.
Resolves this issue.

Possible errors:

  • When named path wasn't found:
Panic: failed to embed code fragment into doc file `file:///Users/vladyslav.kuksiuk/Desktop/Work/embed-code-go/my-test/target/target.md:2`: code root with name `first1` not found for path `$first1/hello/Hello.kt`
  • When source file was found, but fragment wasn't:
Panic: failed to embed code fragment into doc file `file:///Users/vladyslav.kuksiuk/Desktop/Work/embed-code-go/my-test/target/target.md:2`: fragment `main1` from code file `file:///Users/vladyslav.kuksiuk/Desktop/Work/embed-code-go/my-test/source/hello/Hello.kt` not found
  • When source file was not found, by named path:
Panic: failed to embed code fragment into doc file `file:///Users/vladyslav.kuksiuk/Desktop/Work/embed-code-go/my-test/target/target.md:2`: fragment `main` from code file `$first/hello/Hello2.kt (/Users/vladyslav.kuksiuk/Desktop/Work/embed-code-go/my-test/source/hello/Hello2.kt)` not found
  • When file was not found, by unnamed path:
Panic: failed to embed code fragment into doc file `file:///Users/vladyslav.kuksiuk/Desktop/Work/embed-code-go/my-test/target/target.md:2`: fragment `main` from code file `/Users/vladyslav.kuksiuk/Desktop/Work/embed-code-go/my-test/source/hello/Hello2.kt` not found

Copy link
Copy Markdown
Collaborator

@dmytro-kashcheiev dmytro-kashcheiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vladyslav-Kuksiuk LGTM with few comments to check before merge.

Comment on lines +202 to +204
if err != nil {
panic(err)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method by itself is a helper for logging, maybe it's not a best idea to panic if we can't formate logs correctly.

Comment on lines +215 to +217
if err != nil {
panic(err)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

return "", err
}
if originalCodePath == "" {
return fmt.Sprintf("%s", f.CodePath), nil
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this somekind of a GO typing-trick? to print as %s this looks redundant

return fmt.Sprintf("%s (%s)", f.CodePath, originalCodePath), nil
}

return fmt.Sprintf("%s", originalCodePath), nil
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve diagnostics for files with named code paths

2 participants