-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Added JS exception dialog for failed ajax calls #5273
Conversation
All failed ajax calls in the app will display an exception dialog. This is achieved using a global listener to "ajaxError". The dialog will show the exception returned by the server in JSON format with a stack trace if available. Fixes #5226
Here is how the dialog looks like: To produce the error, I've added the following line in apps/files/ajax/delete.php:
Then try and delete a file, the ajax request will fail and the dialog will popup. Please review @karlitschek @DeepDiver1975 @schiesbn @jancborchardt In the meantime I'll look into writing unit tests for the server side part. |
@@ -0,0 +1,13 @@ | |||
<div id="{dialog_name}" title="{title}"> | |||
<div><span class="label">Error: </span><span class="value">{message}</span></div> |
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.
missing translation of Error and below Data and Stack.
Test passed. |
I really don't like this approach 👎
|
The reason I implemented this was because ajax calls were getting a full HTML page response with an exception stack trace embedded in it, which wasn't that easy to spot. In some cases in the files app UI the app seem to just do nothing when you tried to navigate to a subdir. Sometimes there are also exceptions happening in the background (for example exceptions during scanning) and nobody might notice as the UI doesn't show any error. @tanghus I guess you're right, the exception handler should be implemented in the files app directly then instead of globally. Would it still be acceptable to globally log the exception to console.error to make it a bit more visible ? AFAIK the global handler doesn't prevent/block the user's error callback code from $.ajax so RESTful should still work. (I can double check this) |
Can we make this depend on the debug config flag? |
Yes, that has baffled be sometimes too.
I think it should be logged in the log file. Server side error should be in the server log.
The exception and where it happened should be logged with OCP\Util::ERROR and the backtrace with OCP\Util::DEBUG |
So what is the next step here? :-) |
I don't have a good feeling about this dialog any more. |
Or |
Before this PR there is only an entry added into the owncloud log, but without stack trace (I do have XDebug enabled): Nothing appears in Apache's error log. Is there an existing way how to output messages there ? |
It doesn't necessarily have to be in the error log - owncloud.log is better to use, I just wasn't sure if the logging mechanism was available here. For outputting the entire bt just use the same method as you did in the JSON response and write one enumerated log statement per row. Or use |
I've sent another pull request for just the logging. |
All failed ajax calls in the app will display an exception dialog.
This is achieved using a global listener to "ajaxError".
The dialog will show the exception returned by the server in JSON format
with a stack trace if available.
Fixes #5226