kylefarris / clamscan

A robust ClamAV virus scanning library supporting scanning files, directories, and streams with local sockets, local/remote TCP, and local clamscan/clamdscan binaries (with failover).
MIT License
236 stars 69 forks source link

On TCP Socket error, pass the error details #104

Closed stheine closed 2 years ago

stheine commented 2 years ago

Hi @kylefarris ,

it would be great, if you could merge and release my PR. this is needed, as there are situations when I need to know the TCP Socket error details, eg. when the clamd returns INSTREAM size limit exceeded. ERROR (file size exceeding MaxFileSize).

Regards stheine

kylefarris commented 2 years ago

The error details are already being passed with that NodeClamError object as data.err as well as the details of the file in data.file.

So, in the example for the PR you submitted:

try {
    await clam.isInfected('some_file.txt');
} catch (err) {
    console.error(err, err.data.err, err.data.file);
}
stheine commented 2 years ago

ok, thanks, I didn't realize that handling in the NodeClamError. then please drop my PR. thanks for the quick answer.

kylefarris commented 2 years ago

It's not your fault--it's not documented. Documenting it in the README would be a great PR, though. 😉 😉