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

Improve error message from Insert Text at Cursor brick #8063

Closed
grahamlangford opened this issue Mar 25, 2024 · 3 comments · Fixed by #8069
Closed

Improve error message from Insert Text at Cursor brick #8063

grahamlangford opened this issue Mar 25, 2024 · 3 comments · Fixed by #8069
Assignees
Labels
user experience Improve the user experience (UX)

Comments

@grahamlangford
Copy link
Collaborator

grahamlangford commented Mar 25, 2024

User Story

As a PixieBrix mod developer, I want meaningful error messages for the Insert Text at Cursor brick in the Page Editor, so that I can debug errors myself

Motivation

See: https://pixiebrix.slack.com/archives/C0436P48QHY/p1711401954499719

@twschiller
Copy link
Contributor

twschiller commented Mar 25, 2024

Potential message: "Unable to insert text at cursor. Is there an active text editor?" We should ensure we pass along the original error as the cause

@fregante
Copy link
Collaborator

There's no original error, this is the result of execCommand returning false. This specifically happens when there's no field focused/selected or if the field is read-only.

As seen in the last related PR, we generally don't try to get the selected/focused field before running execCommand unless necessary.

@twschiller twschiller added the user experience Improve the user experience (UX) label Mar 26, 2024
@twschiller
Copy link
Contributor

There's no original error, this is the result of execCommand returning false.

The "original error" is here:

throw new Error("Failed to insert text using execCommand");
. So we either need to change that error, or wrap it in InsertAtCursorEffect. I would wrap it and keep the error thrown by insertAtCursorWithCustomEditorSupport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user experience Improve the user experience (UX)
Projects
None yet
3 participants