Merge pull request #4290 from sujeshthekkepatt/fix/hasone-relation-error-message
feat: change hasone relation error message
This commit is contained in:
commit
6a7fc529fc
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue