-
Notifications
You must be signed in to change notification settings - Fork 53
Clean up error messages displayed in the error box #756
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
Conversation
src/ipc-handlers.ts
Outdated
| ); | ||
| await showMessageBox( event, { | ||
|
|
||
| console.error( filteredError ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not make this method responsible of logging the error and leave it up for the caller.
Given #753, we could clean logic around filteredError and error in this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be preferable to display the error twice than none.
We could display some empty lines and a clear text in the log, like: "ERROR REPORTED:" or "ERROR OCCURRED:". This way the user and we would be much more sure about what error was the responsible of the alert.
Here is a possible implementation:
const errorMessage = ( error as Error )?.message;
if ( errorMessage ) {
console.error( '\n\n\n\n\n\nERROR REPORTED:\n' + errorMessage );
}
If we follow this path, we could rename the parameter name from error to errorToLog, so it's clear that the error will be logged in this function.
This is an example of how it would look:
I also see Wojtek's point of view from the perspective of a single responsibility, so open to other ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's remove the logging from this error and filteredError handling as those are solved outside the method scope.
Co-authored-by: Wojtek Naruniec <[email protected]>
sejas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, and it works as expected.
Not approving it until we decide if we should log or not the error.
I also see a possibility to display the first line of characters of the error inside the alert, that way users could share a screenshot of Studio too. But it's not a strong opinion.
I wonder if there are errors where we show the alert and we don't log them into the file. Then in those cases the "Open Studio logs" button would be misleading.
I only tested it on Mac:
Clicking the Open Studio logs it opens the console app with the correct file almost at the bottom:
src/ipc-handlers.ts
Outdated
| ); | ||
| await showMessageBox( event, { | ||
|
|
||
| console.error( filteredError ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be preferable to display the error twice than none.
We could display some empty lines and a clear text in the log, like: "ERROR REPORTED:" or "ERROR OCCURRED:". This way the user and we would be much more sure about what error was the responsible of the alert.
Here is a possible implementation:
const errorMessage = ( error as Error )?.message;
if ( errorMessage ) {
console.error( '\n\n\n\n\n\nERROR REPORTED:\n' + errorMessage );
}
If we follow this path, we could rename the parameter name from error to errorToLog, so it's clear that the error will be logged in this function.
This is an example of how it would look:
I also see Wojtek's point of view from the perspective of a single responsibility, so open to other ideas.
src/ipc-handlers.ts
Outdated
| detail: error ? `${ message }\n\nError: ${ filteredError }` : message, | ||
| buttons: [ __( 'OK' ) ], | ||
| detail: message, | ||
| buttons: [ __( 'Open Studio logs' ), __( 'OK' ) ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we display the "Open Studio logs" buttons in all the cases? or just when we receive the "errorToLog" parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! We could use a param, e.g. showOpenLogs, that is set to false by default, and we can enable it per the case.
| const response = await showMessageBox( event, { | ||
| type: 'error', | ||
| message: title, | ||
| detail: error ? `${ message }\n\nError: ${ filteredError }` : message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's bring it back so the specific error can still be appended, but let's drop the 'Error: '.
src/ipc-handlers.ts
Outdated
| ); | ||
| await showMessageBox( event, { | ||
|
|
||
| console.error( filteredError ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's remove the logging from this error and filteredError handling as those are solved outside the method scope.
src/ipc-handlers.ts
Outdated
| detail: error ? `${ message }\n\nError: ${ filteredError }` : message, | ||
| buttons: [ __( 'OK' ) ], | ||
| detail: message, | ||
| buttons: [ __( 'Open Studio logs' ), __( 'OK' ) ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! We could use a param, e.g. showOpenLogs, that is set to false by default, and we can enable it per the case.
|
@bcotrim my bad, I was wrong on |
| "Please verify your site's local path directory contains the standard WordPress installation files and try again. If this problem persists, please contact support." | ||
| ), | ||
| error, | ||
| showOpenLogs: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm enabling a new button for cases in which Studio can't start the site.
Will add more under https://github.com/Automattic/dotcom-forge/issues/10143
Related issues
Proposed Changes
showErrorMessageBoxTesting Instructions
Prerequisites
npm startTest Scenarios
Error Dialog Display
showOpenLogsis trueLog File Access
Dialog Dismissal
Expected Results
showErrorMessageBoxfunctionPre-merge Checklist