Skip to content
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

Catch UncaughtException when serving in non-Markbind directories #2592

Merged
merged 7 commits into from
Feb 20, 2025

Conversation

AgentHagu
Copy link
Contributor

@AgentHagu AgentHagu commented Feb 3, 2025

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Overview of changes:
Fixes #2570

Currently, there is an issue when using the markbind serve command in non-Markbind directories, leading to an UncaughtException that is displayed to the user.

The problem seems to be due to be a missing process.exit() after catching the error. This leads to the code continuing on despite the rootFolder still being undefined.

The PR also updates the error message to be more user-friendly.

Anything you'd like to highlight/discuss:
This PR only fixes the UncaughtException issue, not the underlying issue mentioned in #1825.

Testing instructions:
Try using the markbind serve command in a non-Markbind directory. The UncaughtException should not show. For example:
image

Proposed commit message: (wrap lines at 72 characters)
Catch UncaughtException when serving in non-Markbind directories


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

Copy link
Contributor

@Tim-Siu Tim-Siu left a comment

Choose a reason for hiding this comment

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

Thanks for the good catch! The process is indeed supposed to exit after catching the error.

Copy link
Contributor

@gerteck gerteck left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@gerteck gerteck left a comment

Choose a reason for hiding this comment

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

LGTM! Nice catch! Love the simple fix 👍

@tlylt
Copy link
Contributor

tlylt commented Feb 12, 2025

@AgentHagu could we take this opportunity to improve the error message, adding something along the line of "this directory does not appear to contain a MarkBind site"

@lhw-1
Copy link
Contributor

lhw-1 commented Feb 16, 2025

Agreed with @tlylt; the fix itself atm is good to go, but we can include the error message display in this PR as well @AgentHagu

@AgentHagu
Copy link
Contributor Author

AgentHagu commented Feb 17, 2025

@tlylt @lhw-1 Thanks for the suggestion! As discussed, I will add an extra message after the existing one for better user readability

@AgentHagu
Copy link
Contributor Author

AgentHagu commented Feb 17, 2025

I've updated the error message to look like this now

image

@lhw-1
Copy link
Contributor

lhw-1 commented Feb 18, 2025

I'm thinking we can also include suggestions, for beginner friendliness: e.g. "This directory does not appear to contain a valid MarkBind site. Check that you are running the command in the correct directory!"

@AgentHagu
Copy link
Contributor Author

I'm thinking we can also include suggestions, for beginner friendliness: e.g. "This directory does not appear to contain a valid MarkBind site. Check that you are running the command in the correct directory!"

Sounds good! Will adjust the message accordingly

@AgentHagu
Copy link
Contributor Author

I have updated the PR to add the suggestions

Copy link
Contributor

@lhw-1 lhw-1 left a comment

Choose a reason for hiding this comment

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

LGTM! A simple but useful fix for those new to MarkBind. Thanks @AgentHagu!

@lhw-1 lhw-1 added the r.Patch Version resolver: increment by 0.0.1 label Feb 20, 2025
@lhw-1 lhw-1 merged commit 008aa1d into MarkBind:master Feb 20, 2025
10 of 11 checks passed
Copy link

Welcome, @AgentHagu! 🎉 Thank you for your contribution to the MarkBind project!

@lhw-1, please remember to add @AgentHagu as an official contributor to our repository.

See the full list of contributors here. ✨

Copy link

@lhw-1 Each PR must have a SEMVER impact label, please remember to label the PR properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r.Patch Version resolver: increment by 0.0.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UncaughtException when running Markbind Serve in non-Markbind directories.
5 participants