Skip to content

Commit

Permalink
Change signature checks to PyTorchError
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Aug 13, 2018
1 parent cb39959 commit c9b879b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pytorch-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ class PyTorchModelFactory {
signature.length != magic_number.length ||
!signature.every((value, index) => value == magic_number[index]))
{
throw new pickle.Error('Invalid signature.');
callback(new PyTorchError('Invalid signature.', null));
return;
}
var protocol_version = unpickler.load();
if (protocol_version != 1001) {
throw new pickle.Error("Unsupported protocol version '" + protocol_version + "'.");
callback(new PyTorchError("Unsupported protocol version '" + protocol_version + "'.", null));
return;
}
var sysInfo = unpickler.load();
if (!sysInfo.little_endian) {
throw new pickle.Error("Unsupported system.");
callback(new PyTorchError('Unsupported system information.'));
return;
}

var functionTable = {};
Expand Down

0 comments on commit c9b879b

Please sign in to comment.