zkteco-js
Version:
The zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices, extract and manage data, and integrate biometric features into attendance systems efficiently.
45 lines (37 loc) • 970 B
JavaScript
/**
*
* Author: coding-libs
* Date: 2024-07-01
*/
const ERROR_TYPES = {
ECONNRESET: 'ECONNRESET',
ECONNREFUSED: 'ECONNREFUSED',
EADDRINUSE: 'EADDRINUSE',
ETIMEDOUT: 'ETIMEDOUT'
}
class Errors {
constructor(err, command, ip) {
this.err = err
this.ip = ip
this.command = command
}
toast() {
if (this.err.code === ERROR_TYPES.ECONNRESET) {
return 'Another device is connecting to the device so the connection is interrupted'
} else if (this.err.code === ERROR_TYPES.ECONNREFUSED) {
return 'IP of the device is refused'
} else {
return this.err.message
}
}
getError() {
return {
err: {
message: this.err.message, code: this.err.code
}, ip: this.ip, command: this.command
}
}
}
module.exports = {
ZkError: Errors, ERROR_TYPES
}