mirror of
https://github.com/strapi/strapi.git
synced 2025-12-30 00:37:24 +00:00
fractional orderer error management
This commit is contained in:
parent
2e7aa7c2a9
commit
640adedd73
@ -18,7 +18,6 @@ class FractionalOrderer {
|
||||
|
||||
_updateRelationOrder(r) {
|
||||
let idx;
|
||||
// TODO: Throw if the relation does not exist
|
||||
if (r.position.before) {
|
||||
const { idx: _idx, relation } = this.findRelation(r.position.before);
|
||||
if (relation.init) r.order = relation.order - 0.5;
|
||||
@ -53,10 +52,17 @@ class FractionalOrderer {
|
||||
_.castArray(relations).forEach((relation) => {
|
||||
this.disconnect(relation);
|
||||
|
||||
const { relation: _relation, idx } = this._updateRelationOrder(relation);
|
||||
|
||||
// Add to the chunk
|
||||
this.arr.splice(idx, 0, _relation);
|
||||
try {
|
||||
const { relation: _relation, idx } = this._updateRelationOrder(relation);
|
||||
// Add to the chunk
|
||||
this.arr.splice(idx, 0, _relation);
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Could not connect ${relation.id}, position ${JSON.stringify(
|
||||
relation.position
|
||||
)} is invalid`
|
||||
);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user