[jQuery] simple testing of selectors returning empty result
In many situations I use jQuery selector and I want to check that
result is non empty. To make this simple, I use this code:
// jQuery extension to test non-empty select
function
$
{
$.fn.notempty = function
{
if
this.length==0
throw
'Empty jQuery selector'
;
return this;
};
}
jQuery
;
...and than use it like:
$
"#someID"
.notempty
.show
.someotheroperation
;
I use custom error handler for javascript errors:
window.onerror = function
desc,page,line,chr
{ /* my error reporting
*/ }
...but uncaught exception does not end in this handler. Is there any
way to report file and line where this test failed
I mean file and
line with $
"#someID"
.notempty
... from my example
?
Thanks a lot for any hint.