-
Notifications
You must be signed in to change notification settings - Fork 2
feat(page): print the eval-js value bare and use exception_detail for failures #72
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
Merged
giordano-lucas
merged 2 commits into
main
from
t3code/eval-js-output-and-exception-detail
Aug 25, 2026
+281
−27
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/nottelabs/notte-cli/internal/api" | ||
| ) | ||
|
|
||
| func strPtr(s string) *string { return &s } | ||
|
|
||
| // The API sends the failure twice: `exception` is a bare string rendered in the | ||
| // server's ErrorConfig mode (often the generic user-facing sentence), while | ||
| // `exception_detail` carries the concrete type and the per-audience messages. | ||
| // The CLI must report the structured one when it is there. | ||
| func TestExecutionFailureError_PrefersStructuredDetail(t *testing.T) { | ||
| detail := &api.SerializedError{ | ||
| ErrorType: "ActionExecutionError", | ||
| DevMessage: "Failed to execute action: evaluate_js on https://x. Reason: ReferenceError: foo is not defined", | ||
| UserMessage: "Sorry, this action cannot be executed at the moment.", | ||
| } | ||
|
|
||
| err := executionFailureError(detail, strPtr("Sorry, this action cannot be executed at the moment."), "boom") | ||
|
|
||
| got := err.Error() | ||
| if !strings.Contains(got, "ActionExecutionError") { | ||
| t.Fatalf("expected the concrete error type, got %q", got) | ||
| } | ||
| if !strings.Contains(got, "ReferenceError: foo is not defined") { | ||
| t.Fatalf("expected the actual reason, got %q", got) | ||
| } | ||
| if strings.Contains(got, "Sorry, this action cannot be executed") { | ||
| t.Fatalf("expected the generic user message to be dropped, got %q", got) | ||
| } | ||
| } | ||
|
|
||
| func TestExecutionFailureError_FallsBackToUserMessage(t *testing.T) { | ||
| detail := &api.SerializedError{ErrorType: "BrowserError", UserMessage: "Something unexpected happened."} | ||
|
|
||
| err := executionFailureError(detail, nil, "") | ||
|
|
||
| if got := err.Error(); got != "BrowserError: Something unexpected happened." { | ||
| t.Fatalf("unexpected error: %q", got) | ||
| } | ||
| } | ||
|
|
||
| // API builds that predate exception_detail send only the legacy string. | ||
| func TestExecutionFailureError_LegacyExceptionString(t *testing.T) { | ||
| err := executionFailureError(nil, strPtr("boom"), "click failed") | ||
|
|
||
| if got := err.Error(); got != "boom: click failed" { | ||
| t.Fatalf("unexpected error: %q", got) | ||
| } | ||
| } | ||
|
|
||
| func TestExecutionFailureError_MessageOnly(t *testing.T) { | ||
| err := executionFailureError(nil, nil, "click failed") | ||
|
|
||
| if got := err.Error(); got != "action failed: click failed" { | ||
| t.Fatalf("unexpected error: %q", got) | ||
| } | ||
| } | ||
|
|
||
| func TestExecutionFailureError_NothingToGoOn(t *testing.T) { | ||
| err := executionFailureError(nil, nil, "") | ||
|
|
||
| if got := err.Error(); got != "action failed" { | ||
| t.Fatalf("unexpected error: %q", got) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.