Skip to content

error handling: use user-error and rely on early abort control flow#154

Open
wbolster wants to merge 2 commits into
sshaw:masterfrom
wbolster:error-handling
Open

error handling: use user-error and rely on early abort control flow#154
wbolster wants to merge 2 commits into
sshaw:masterfrom
wbolster:error-handling

Conversation

@wbolster

@wbolster wbolster commented Jul 9, 2026

Copy link
Copy Markdown

Use ‘user-error’ to signal errors, e.g. missing remotes, etc.

Unlike ‘message’, this causes an early return from the defun, so many
conditionals like ‘if’ and ‘cond’ are no longer needed.

Fixes #45.

wbolster added 2 commits July 9, 2026 11:39
Run ‘M-x untabify’ the whole file to avoid mixing tabs and spaces
Use ‘user-error’ to signal errors, e.g. missing remotes, etc.

Unlike ‘message’, this causes an early return from the defun, so many
conditionals like ‘if’ and ‘cond’ are no longer needed.

Fixes sshaw#45.
@sshaw

sshaw commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Hi, thanks for the pull request!

Wow almost 10 years since you opened the issue. Glad to see you're still here and using git-link! ❤️

Going back to the original issue (😅), I think the desire for user-error is symptom of the real issue: git-link is an interactive function, and people want to call it programmatically. Given this, wouldn't it better to extract the link generation into its own, "public", non-interactive function, that can signal via user-error, and the interactive version can handle it and continue to use message?

My thought process is mostly based on the premise that user-error is not for interactive functions, which may not be correct? It certainly can work in certain contexts but say if one has command-error-function configured, do you want that output into the minibuffer when calling this interactively?

Thoughts?

@sshaw

sshaw commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Also in #45 you said:

i recently noticed that git-link doesn't report errors correctly

Do you just mean when calling it non-interactively or something else?

@wbolster

Copy link
Copy Markdown
Author

the good news is that you're wrong 🙃:

user-error is fine for interactive commands; in fact it's how many built-ins signal a ‘problem’, such as previous-line while point is already on the first line of the file; see the docs on user-error

additionally, having a programmatic interface would be helpful indeed, b/c it would mean it can be called without accidentally opening a browser (depending on config etc), but that seems like a separate undertaking which can be done afterwards?

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.

use user-error to signal errors

2 participants