coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.72k stars 240 forks source link

Refactored error handlings #36

Closed mhayashi closed 13 years ago

mhayashi commented 13 years ago

Hi,

I have refactored error handlings.

I added some error handlings last month. At that time, I didn't want to affect to existing functions, so I passed an error object to executeSql()'s callbacks as the 2nd argument. But in asynchronous JavaScript programming, we usually pass an error object to callback as the first argument, and pass null when no error occurs, like this,

An error occurs: callback(err)

No error occurs: callback(null, result)

So, I refactored error handling to pass an error object as the first argument. With this modification, I simplified the exectuteSql()'s interface to pass just one callback instead of passing two callbacks (successFn and errorFn).

All existing tests are passed. Please let me know if there are any problems.

Masahiro

zefhemel commented 13 years ago

Hi, I have not yet integrated this pull request because of this reason: http://groups.google.com/group/persistencejs/browse_thread/thread/8fdc07230b544c52 maybe you can provide some input?