-
Notifications
You must be signed in to change notification settings - Fork 3
ERMrestJS Dev Guide
robes edited this page Mar 8, 2017
·
1 revision
This is the place to document the style and practices that we want to follow in developing ermrestjs.
A few rules to be followed.
- Asynchronous APIs should only communicate errors via the promise mechanism. They should never throw an exception. This allows the client code to be written in an easier to read style rather than wrapping long promise chains in javascript
try/catch
blocks. - Synchronous APIs should only communicate errors via throwing exceptions (i.e., they should not
return
numeric or other error messages). - We should always be careful to handle exceptions or communicate (via exception throwing or promise rejecting) unhandled/unexpected exceptions.
function myasyncfn(paramlist) {
try {
// All logic is wrapped in an outer try/catch block
catch (e) {
// Unexpected exceptions are return via an immediately rejected promise
return module._q.reject(e);
}
},
...