-
-
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
Error handling #383
Comments
my editor keeps crashing and it's really hard to debug atm :( an event would be handy |
ProblemsAt the moment we have far too many errors handling mechanisms. What we have is:
Note that, there are 3 main cases error handling mechanism should solve. Human-friendly feedbackWe want to give nice, human-friendly feedback, for developers who are integrating the editor or creating plugins, as soon as they do something wrong. In most cases Help for debuggingThere is more than just information about the critical exception. Sometimes you need to be able to follow the application flow. Sometimes part of it. However, this information is still only important for developers. They want to be able to disable it for end users. Provide stable editor for end-usersEnd-users want to have a stable application. That's it. For them, we might have some mechanism which will restart the editor in the case of a crash, but the error message is usually not important for them. They need a watchdog mechanism which will listen on global errors and restart the editor in case of an error, not just an error in the console. SolutionMy proposal is to simplify the whole mechanism and have just two tools. CKEditorError expetionThey should replace all To be able to restart the editor by the watchdog, CKEditorError needs a context to be able to identify which editor crashed. The context might be the Additionally Precompiler flagsThe second mechanism can be precompiler flags. For instance:
Should replace:
to:
(note that it should work fine with the sourcemap since the position of characters do not change) I believe that by default some warnings should be enabled (like rendering infinite loop warning or UI
Should still replace:
to:
However, it should be possible to disable it using It should be also possible to add new types of debugging code if needed.
Note that this way not only the console can be used, but any code can be conditionally executed, even imports. Thanks to it, we may use anything we need in the debug mode and do not slow down the production code nor increase the size of the build after the minification. This way engine debug tool should be added to make them work out of the box when Finally, it should not preclude the possibility of using I do not see any reason to keep |
I agree with most of the things and discussed them with @pjasiun F2F, so I'll just focus on the changes I'd propose. It doesn't make sense to have an option like In general, there should be the following levels:
PS. The above means that I'd remove the |
The first part of this task is done, thanks to @ma2ciek, we have a context in all |
Actually, I'm not sure with removing
Otherwise, IDK really how to implement the above using only the native console. And IMO the final result should be much cleaner if we write some magic ifs inside our logger only. |
Since there are no many cases (so far we have one case for warning in the production code, missing upload adapter), we can simply do:
Note that for all
Note that we should not change them in the CK_DEBUG mode. We should throw only in our automatic tests. In manual tests, they should act in a normal way. I think that in unit tests we can simply overwrite |
I think I agree with both things that @pjasiun wrote. We can KISS now. |
@pjasiun How you want to achieve it for all our tests? With a regexp replacement in pre-processing? |
I think that in pre-processing we should be able to add code which will be executed before tests and will simply overwrite these properties (I mean, like |
With this approach, we need to create a webpack plugin that would access the bundle and inject such code that will affect every usage of We could add a |
All of them come from Karma WebServer and I'm pretty sure that we don't want to change anything in external tools. Some of those logs can contain useful information for developers (e.g. when you specify invalid fields in configuration object). |
Do you mean this?
These are not warnings coming from I don't see any console log coming from the browser, so I think we can safely override it. Can be |
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
What I should do with the incorrect situation? Is it caused by the wrong editor integration?Yes. Does it a common error, which many developers may meet at the early stage of integration and we are able to initialize the editor despite it?Yes.Use No.Throw No, the error is usually a result of the user action. May it happen in a correct situation?Yes/Maybe.Use No, the situation is definitely incorrect.Throw |
I believe that the next step to close this issue is to turn |
Internal: Removed usage of the CKEditor 5 logger. Part of ckeditor/ckeditor5#383.
Other: Removed the CKEditor 5 logger and its usage. Part of ckeditor/ckeditor5#383. BREAKING CHANGE: Removed the CKEditor 5 logger utility.
Feature: Added support for debugging flags in automated and manual tests available via the `--debug` (`-d`) flag. Closes ckeditor/ckeditor5#383.
We have
log.warn
andlog.error
utils: https://github.com/ckeditor/ckeditor5-utils/blob/master/src/log.js for a long time, and it's still unclear what they should do.log.error
should be called when something very bad happens and the editor will crash. Such situation could be handled: a plugin or integration could report the error or reinitialize the editor. To do it, it needs to know that the error occurred.This is why these methods should fire event. The problem is, on what object they should fire that event. The third parameter should be passed with the
context
, object on which event should be fired.On the other hand, we do not want to hide the error: it should be thrown anyway from the
catch
block, so there will be the stack trace in the console.To let users handle the error we should add
try-catch
block in places we know that error can occur (for instancedocument.enqueueChanges
). Another problem is thatdocument
knows nothing about theeditor
, so we need to propagate the event: editor can listen on the document and propagateerror
event.The text was updated successfully, but these errors were encountered: