Skip to content

Commit 11c6236

Browse files
committed
fix check hdiff fail when cancel compress
1 parent c8275c1 commit 11c6236

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/hdiff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ void hdiff(const uint8_t* old,size_t oldsize,const uint8_t* _new,size_t newsize,
3232

3333
if (!check_single_compressed_diff(_new,_new+newsize,old,old+oldsize,out_codeBuf.data(),
3434
out_codeBuf.data()+out_codeBuf.size(),decompressPlugin)){
35-
throw std::runtime_error("create_single_compressed_diff() out data error!");
35+
throw std::runtime_error("check_single_compressed_diff() fail, diff code error!");
3636
}
3737
}

src/main.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <node.h>
66
#include <node_buffer.h>
77
#include <cstdlib>
8+
#include <string>
89
#include "hdiff.h"
910

1011
using namespace std;
@@ -63,10 +64,11 @@ namespace hdiffpatchNode
6364
try{
6465
hdiff((const uint8_t*)oldData,oldLength,(const uint8_t*)newData,newLength,codeBuf);
6566
}catch(const std::exception& e){
66-
Nan::ThrowError("Create hdiff failed.");
67+
std::string errInfo("Create hdiff failed : "); errInfo+=e.what();
68+
Nan::ThrowError(errInfo.c_str());
6769
}
6870
if (0!=callback_write(&streamOpaque,codeBuf.data(),codeBuf.size()))
69-
Nan::ThrowError("Write DiffStreamOpaque failed.");
71+
Nan::ThrowError("Create hdiff failed : Write data to DiffStreamOpaque fail.");
7072

7173
// args.GetReturnValue().Set(returnObj);
7274
// args.GetReturnValue().Set(String::NewFromUtf8(isolate, bufferData, String::kNormalString, bufferLength));

0 commit comments

Comments
 (0)