godaddy / datastar

A robust and feature rich ODM for Cassandra.
MIT License
40 stars 12 forks source link

Add error event listener to model EventEmitter to capture Model action error responses #64

Closed jsalloway-godaddy closed 1 year ago

jsalloway-godaddy commented 1 year ago

Receiving an error response from a Model action is currently not caught by the Model’s event emitter, which instead causes a process.exit(1) to be triggered. Adding an error event listener as part of the Model allows these errors to be captured without service termination.

I’ve only implemented a basic console.error as part of the listener. I did try to implement an errorCallback that consumers can provide via the options parameter in lib/index.js:92 but this was breaking existing functionality when arguments are manipulated.

jcruger-godaddy commented 1 year ago

@jsalloway-godaddy Reading the code it seems that this should be handled via

Model.on(‘error’, () =>

does that not work? I’d like to see the application level code

jsalloway-godaddy commented 1 year ago

@jcruger-godaddy You're correct, adding a listener to the Model in our codebase has provided the same functionality.