Skip to content

Commit

Permalink
Return NaN when encountering unregular value length number. Do not
Browse files Browse the repository at this point in the history
throw. Fixes #112.
  • Loading branch information
ivmartel committed Sep 30, 2014
1 parent 89f03d6 commit 5446bc3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/dicom/dicomParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ dwv.dicom.DataReader = function(buffer, isLittleEndian)
return this.readFloat32(byteOffset, isLittleEndian);
}
else {
console.log("Non number: '"+this.readString(byteOffset, nBytes)+"'");
throw new Error("Unsupported number size.");
console.warn("Non number: '"+this.readString(byteOffset, nBytes)+"' of "+nBytes+" bytes.");
return Number.NaN;
}
};
/**
Expand Down Expand Up @@ -340,7 +340,11 @@ dwv.dicom.DicomParser.prototype.readDataElement = function(reader, offset, impli
var dataOffset = offset+tagOffset+vrOffset+vlOffset;
if( vr === "US" || vr === "UL")
{
data = [reader.readNumber( dataOffset, vl )];
var num = reader.readNumber( dataOffset, vl );
if ( isNaN(num) ) {
console.warn("Not a number returned for tag: "+tag.name);
}
data = [num];
}
else if( vr === "OW" )
{
Expand Down

0 comments on commit 5446bc3

Please sign in to comment.