From my project unit tests I've identified that in order to get identical errors returned from a local or remote database you need the following code change
if (typeof e.unauthorized !== "undefined") {
throw {
name: "unauthorized",
message: 'Name or password is incorrect.',
reason: e.unauthorized,
status: 401
};
} else if (typeof e.forbidden !== "undefined") {
throw {
name: "forbidden",
message: 'Forbidden by design doc validate_doc_update function',
reason: e.forbidden,
status: 403
};
- renamed
message field to reason
- added new message field text