feat: change hasone relation error message

The current hasone error message is not appropriate one.
So adds a better message.
This commit is contained in:
Sujesh T 2019-11-30 17:21:25 +05:30
parent 2db09a3d00
commit b93187b0f9
2 changed files with 8 additions and 1 deletions

View File

@ -565,7 +565,9 @@ module.exports = function(registry) {
if (ctx.result !== null) return cb();
const fk = ctx.getArgByName('fk');
const msg = g.f('Unknown "%s" id "%s".', toModelName, fk);
const msg = fk ?
g.f('Unknown "%s" id "%s".', toModelName, fk) :
g.f('No "%s" instance(s) found', toModelName);
const error = new Error(msg);
error.statusCode = error.status = 404;
error.code = 'MODEL_NOT_FOUND';

View File

@ -1810,6 +1810,11 @@ describe('relations - integration', function() {
const url = '/api/customers/' + cust.id + '/profile';
this.get(url)
.expect(404, function(err, res) {
const expected = 'No "profile" instance(s) found';
expect(res.body.error.message).to.be.equal(
expected,
);
expect(res.body.error.code).to.be.equal('MODEL_NOT_FOUND');
done(err);
});
});