-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
"CKEditor Unexpected error" wrapper makes errors unreadable #5595
Comments
Hm. The core of the problem seems to be displaying the |
Hm... IDK. It requires some tests, but I'd start from checking what we can keep in the error message. Because I don't think we can expect that |
We can't have an error instance passed directly, because the {
originalError: {
message: err.message,
stack: err.stack,
name: err.name
}
} Of course, this data could be kept also as such structure: {
message: err.message,
stack: err.stack,
name: err.name
} But it won't change anything in case of displaying the error stack properly. |
The other thing that comes to my mind is that we can overwrite the stack trace of the E.g.: static rethrowUnexpectedError( err, context ) {
if ( err.is && err.is( 'CKEditorError' ) ) {
throw err;
}
const ckeditorError = new CKEditorError( 'unexpected-error: Unexpected error occurred.', context, {
message: err.message,
name: err.name
} );
ckeditorError.stack = err.stack;
throw ckeditorError;
} This construction introduces a little bit of magic but it should make the error stack look good and be clickable. EDIT: Actually we could override the |
cc @mlewand, what do you think about the proposed solutions? |
I believe that we should forward errors when the editor is built with |
If it works well in all browsers, then I think it's a good idea. If not, I'd do a custom error message getter for cases where error's additional data is an instance of an error. |
This replacement, unfortunately, doesn't print the stack trace well on Safari. It works well on Chrome and FF though. On Safari the stack trace is created once the error is thrown, not when the error is created, thus replacing it doesn't change anything. Comparison of the original errors and the rethrown errors: The original error could be logged, however it doesn't sound like a good solution. |
At least it's something better for majority of users :) |
I guess we can change this multiple times – i.e. try with this and then improve if we'll see that it wasn't enough. Optionally, if you think that the above result is still bad, we can add do it our |
Great 👍
Can we add the |
AFAIU rethrowing will still change the stack trace on Safari? That'd be a bummer, but I guess the only alternative would be something like: try {
if ( this._pendingChanges.length === 0 ) {
// If this is the outermost block, create a new batch and start `_runPendingChanges` execution flow.
this._pendingChanges.push( { batch: new Batch(), callback } );
return this._runPendingChanges()[ 0 ];
} else {
// If this is not the outermost block, just execute the callback.
return callback( this._currentWriter );
}
} catch ( err ) {
// @if CK_DEBUG // throw err;
CKEditorError.rethrowUnexpectedError( err, this );
} But I don't know how the above will differ from what you proposed. Could you show some stack traces that both solutions will produce? |
Dunno. Let's see it live and decide. We're not debugging things on Safari too often anyway, so we could most likely live without this anyway. Do changes that you think will be fine, let's merge them and if we'll be still complaining then we can think further. |
Internal: Adjusted manual test description to changes in error handling. Part of ckeditor/ckeditor5#5595.
Internal: Rethrow original error in try-catch blocks when the `debug=true` mode is on. Part of ckeditor/ckeditor5#5595.
Internal: Rethrow original error in try-catch blocks when the `debug=true` mode is on. Part of ckeditor/ckeditor5#5595.
Internal: Rethrow original error in try-catch blocks when the `debug=true` mode is on. Part of ckeditor/ckeditor5#5595.
Fix: Improved error rethrowing by replacing the error stack. Closes ckeditor/ckeditor5#5595.
Good luck analysing where this issue occurred:
We need to improve this as this will be a big PITA.
The text was updated successfully, but these errors were encountered: