mirror of
https://github.com/strapi/strapi.git
synced 2025-12-26 22:54:31 +00:00
Lifecycle pre callbacks can be cancelled
In case that any Lifecycle pre callback returns Promise.reject it will be caught by Admin UI showing error banner. It allows custom validations with Lifecycle callbacks as well Admin UI will show saving process without it in case of error inside Lifecycle callback just writing error message in log.
This commit is contained in:
parent
82b36df90c
commit
c51c6b06c5
@ -129,10 +129,9 @@ module.exports = ({ models, target, plugin = false }, ctx) => {
|
||||
|
||||
if (_.isFunction(target[model.toLowerCase()][fn])) {
|
||||
schema.pre(key, function(next) {
|
||||
target[model.toLowerCase()]
|
||||
return target[model.toLowerCase()]
|
||||
[fn](this)
|
||||
.then(next)
|
||||
.catch(err => strapi.log.error(err));
|
||||
.then(next);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user