Warning level control - with suggestion
Warning level control - with suggestion
wellsbr01
Posts: 2Questions: 0Answers: 0
If I may suggest the following code to _fnLog, to add a more flexible control of warnings and debugging:
[code]
function _fnLog( oSettings, iLevel, sMesg )
{
var sAlert = (oSettings===null) ?
"DataTables warning: "+sMesg :
"DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
if ( iLevel === 0 )
{
if ( DataTable.ext.sErrMode == 'alert' )
{
alert( sAlert );
}
else if ( DataTable.ext.sErrMode == 'thow' )
{
throw sAlert;
}
else if ( DataTable.ext.sErrMode == 'console' )
{
console.log( sAlert );
}
else if ( DataTable.ext.sErrMode == 'mute' )
{}
return;
}
else if ( console !== undefined && console.log )
{
console.log( sAlert );
}
}
[/code]
Along with adding the usual sErrMode param on the user code:
[code]
$(function () {
$.fn.dataTableExt.sErrMode = 'mute'; //check above for other options
//.... code ....
});
[/code]
What it adds is flexibility to improve faster development when facing non-disruptive warning situations. In my case it kept issued warnings but in the end the result was a perfect DT anyway. So making it mute was just fine (it was getting really boring with the alerts and just blocking with the throw).
It is working nicely this way. Just to consider.
Thanks,
Wellington
[code]
function _fnLog( oSettings, iLevel, sMesg )
{
var sAlert = (oSettings===null) ?
"DataTables warning: "+sMesg :
"DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
if ( iLevel === 0 )
{
if ( DataTable.ext.sErrMode == 'alert' )
{
alert( sAlert );
}
else if ( DataTable.ext.sErrMode == 'thow' )
{
throw sAlert;
}
else if ( DataTable.ext.sErrMode == 'console' )
{
console.log( sAlert );
}
else if ( DataTable.ext.sErrMode == 'mute' )
{}
return;
}
else if ( console !== undefined && console.log )
{
console.log( sAlert );
}
}
[/code]
Along with adding the usual sErrMode param on the user code:
[code]
$(function () {
$.fn.dataTableExt.sErrMode = 'mute'; //check above for other options
//.... code ....
});
[/code]
What it adds is flexibility to improve faster development when facing non-disruptive warning situations. In my case it kept issued warnings but in the end the result was a perfect DT anyway. So making it mute was just fine (it was getting really boring with the alerts and just blocking with the throw).
It is working nicely this way. Just to consider.
Thanks,
Wellington
This discussion has been closed.
Replies
Thanks!
Allan
Thanks for considering this, Allan.
I would like to add one more idea:
A callback would also be extremely useful. This would allow the user to write their own error handler, such as a silent AJAX POST in the background to send a message to the admins/etc.
Thanks,
Allan
Bump! Have just come across this at $WORK and would prefer a configurable error handler. According to http://stackoverflow.com/questions/11941876/correctly-suppressing-warnings-in-datatables it's only possible by changing DataTable's source... Don't mind trying to knock up a prototype if that'd be even possible.