|
window.onerror не ловит DA PL/SQL exception
|
|||
---|---|---|---|
#18+
Братцы, поделитесь мнением и опытом, что не так стряслось с 18, поскольку с 5 все было распрекрасно. Проверить просто. Создайте страничку с кнопкой на которой DA c PL/SQL кодом: Код: plsql 1. 2. 3.
Добавьте код Код: javascript 1.
в раздел "Execute when Page Loads" страницы. Кликание на кнопку подтвердит моё отверждение: ... |
|||
:
Нравится:
Не нравится:
|
|||
09.12.2018, 08:38 |
|
window.onerror не ловит DA PL/SQL exception
|
|||
---|---|---|---|
#18+
... |
|||
:
Нравится:
Не нравится:
|
|||
10.12.2018, 20:45 |
|
window.onerror не ловит DA PL/SQL exception
|
|||
---|---|---|---|
#18+
Саша Сплинтер, На крайний случай есть apex.server.process или плагины. Не заморачивался я этим. ... |
|||
:
Нравится:
Не нравится:
|
|||
10.12.2018, 22:03 |
|
window.onerror не ловит DA PL/SQL exception
|
|||
---|---|---|---|
#18+
Джон Шнайнер ответил. Благодарность ему, конечно... Но закат солнца вручную обеспечен... И какой смысл сначала строить IDE, а потом для иэлементарных действия обработки ошибок предлагать писать вручную код для организации DA PL/SQL? Ребята явно перемудрили... This change in behavior was announced in the 18.1 release notes: "5.1.19 Ajax Error Message on Server and dynamic_actions_core JavaScript Modules Changed The Oracle Application Express server and dynamic_actions_core JavaScript modules no longer call window.onerror when there is an Ajax error." It didn't get into the reason why. The reason has to do with the new Developer Toolbar feature that shows a red button when there is a JavaScript error. Part of the way this works is that APEX installs an onerror handler. We did not want the default behavior of apex.server.process/plugin and DAs that do ajax to invoke the APEX onerror handler in place of the default messaging. We do not think that window.onerror was/is a very good way to handle errors for a number of reasons: (We also didn't find that it was used much.) 1) There is just one window.onerror function and this can cause collisions if multiple modules want to add a function there. Yes you can use $(window).on("error", function() {...}) but then APEX wouldn't call your function. It only used window.onerror. Which leads to the next reason 2) What APEX had been doing wasn't really the right thing. An error message returned from an ajax call isn't a JavaScript error. Calling window.onerror as a function isn't really proper. 3) In general friendly messages should be supplied by the server and there are server side APIs for doing that. That said I'm not too familiar with those APIs or how to use them so they may or may not be helpful in this specific situation. 4) Using window.onerror is not very modular since you have no idea where the error is coming from. If you have 20 different ajax requests and want to handle errors for all of them in one place you end up with a big switch or if then else block. It is better to use try catch if it is truly a JavaScript error or add your own error handling function if using apex.server functions. The bottom line is that the server side implementation should provide nice messages. If there isn't a way to do this with Execute PL/SQL DA actions then we have a problem but window.onerror is not the solution. The client side should only be concerned with the presentation of the message. And for that we don't currently give much control in the default error handler but if we improve this in the future I expect it would be through the apex.message namespace. Currently the default error message presentation for apex.server.process/plugin and default error message presentation for DA ajax errors is different. The former uses apex.message.showErrors and the later uses apex.message.alert. This is an issue. I think ideally they would both use showErrors. And again give control over the presentation. I don't really have a simple workaround for you for the exact example you give. Some options would be - to look into server side error APIs to see if they also work for Execute PL/SQL DA actions, - catch any errors and put the nice message in a hidden page item - switch to using apex.server.process which gives more control over error handling There is room for APEX to improve here but I'm not exactly sure what the best solution is. It requires more thought. I do know that bringing back the old way of calling window.onerror is not the right thing to do. Note that assigning to window.onerror as you have shown window.onerror = function(pMessage){ alert('Friendly error.'); } will still work for handling JavaScript errors as it is intended to do but it will also overwrite the APEX onerror handler that adds the red dev toolbar button. (note to self maybe we should guard against this) What you should do is use $(window).on("error", function(..) {...}); or var originalErrorHandler = window.onerror; window.onerror = function(arg) { // do something if (originalErrorHandler) { originalErrorHandler(arg); } }; But again I don't think that onerror handler is very useful in general. Regards, -John ... |
|||
:
Нравится:
Не нравится:
|
|||
11.12.2018, 07:12 |
|
window.onerror не ловит DA PL/SQL exception
|
|||
---|---|---|---|
#18+
Саша Сплинтер, Если интересует только, как поменять текст ошибки, то application error handler умеет это делать, в частности блок из стандартного примера Код: plsql 1. 2. 3. 4.
уберёт лишний текст Ajax call returned server error ora-20000... и выведет просто текст ошибки Ugly error! ... |
|||
:
Нравится:
Не нравится:
|
|||
11.12.2018, 09:03 |
|
window.onerror не ловит DA PL/SQL exception
|
|||
---|---|---|---|
#18+
Да, слушай, такой обработчик у меня работает. Как-то не подумал, что можно в нём подчистить и эту белиберду. Спасибо тебе за напоминание. Но, всё-таки я пошёл путём apex.server.process с вызовом API более менее привычного пользователю отображения ошибки. ... |
|||
:
Нравится:
Не нравится:
|
|||
11.12.2018, 12:16 |
|
window.onerror не ловит DA PL/SQL exception
|
|||
---|---|---|---|
#18+
Э нет, не получится. Мой пример не приводит к вызову обработчика ошибок, описанного в настройках приложения. То есть просто не приходит обработка сюда. ... |
|||
:
Нравится:
Не нравится:
|
|||
11.12.2018, 12:53 |
|
|
start [/forum/topic.php?fid=50&gotonew=1&tid=1874076]: |
0ms |
get settings: |
8ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
163ms |
get topic data: |
9ms |
get first new msg: |
7ms |
get forum data: |
2ms |
get page messages: |
42ms |
get tp. blocked users: |
1ms |
others: | 13ms |
total: | 264ms |
0 / 0 |