Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better error handling for missing model error #8328

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/strapi-utils/lib/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ module.exports = {
});
});
} else if (_.has(attribute, 'via') && _.has(attribute, 'collection')) {
if (!_.has(models, attribute.collection)) {
throw new Error(
`The collection \`${_.upperFirst(
attribute.collection
)}\` is missing from the models ${attribute.plugin ? '(plugin - ' + attribute.plugin + ')' : ''}`
TC-42-54 marked this conversation as resolved.
Show resolved Hide resolved
);
}
const relatedAttribute = models[attribute.collection].attributes[attribute.via];

if (!relatedAttribute) {
Expand Down