Skip to content

Commit

Permalink
Updated: When throwing an error, throw a "new Error()" so we can get …
Browse files Browse the repository at this point in the history
…a bit more information about the error

Updated: When using custom sort data types, if the returned array is not of the required length (aoData.length), then an error is thrown
  • Loading branch information
Allan Jardine committed Feb 20, 2012
1 parent 409edd7 commit 793020a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions media/js/jquery.dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -3798,9 +3798,16 @@
if ( DataTable.ext.afnSortData[sDataType] )
{
var aData = DataTable.ext.afnSortData[sDataType]( oSettings, iColumn, iVisColumn );
for ( j=0, jLen=aoData.length ; j<jLen ; j++ )
if ( aData.length === aoData.length )
{
_fnSetCellData( oSettings, j, iColumn, aData[j] );
for ( j=0, jLen=aoData.length ; j<jLen ; j++ )
{
_fnSetCellData( oSettings, j, iColumn, aData[j] );
}
}
else
{
_fnLog( oSettings, 0, "Returned data sort array (col "+iColumn+") is the wrong length" );
}
}
}
Expand Down Expand Up @@ -4533,7 +4540,7 @@
}
else
{
throw sAlert;
throw new Error(sAlert);
}
return;
}
Expand Down
11 changes: 9 additions & 2 deletions media/src/core/core.sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ function _fnSort ( oSettings, bApplyClasses )
if ( DataTable.ext.afnSortData[sDataType] )
{
var aData = DataTable.ext.afnSortData[sDataType]( oSettings, iColumn, iVisColumn );
for ( j=0, jLen=aoData.length ; j<jLen ; j++ )
if ( aData.length === aoData.length )
{
_fnSetCellData( oSettings, j, iColumn, aData[j] );
for ( j=0, jLen=aoData.length ; j<jLen ; j++ )
{
_fnSetCellData( oSettings, j, iColumn, aData[j] );
}
}
else
{
_fnLog( oSettings, 0, "Returned data sort array (col "+iColumn+") is the wrong length" );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion media/src/core/core.support.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function _fnLog( oSettings, iLevel, sMesg )
}
else
{
throw sAlert;
throw new Error(sAlert);
}
return;
}
Expand Down

0 comments on commit 793020a

Please sign in to comment.