feat: Add item information to more node errors (#3681)

*  Add `itemIndex` to node-thrown errors

*  Add some missing item indexes
This commit is contained in:
Iván Ovejero
2022-07-12 17:51:01 +02:00
committed by GitHub
parent a847190f33
commit 2a8043cd27
117 changed files with 376 additions and 370 deletions

View File

@@ -226,7 +226,7 @@ export class Ghost implements INodeType {
} else {
const mobileDoc = validateJSON(content);
if (mobileDoc === undefined) {
throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON');
throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', { itemIndex: i });
}
post.mobiledoc = content;
}
@@ -240,7 +240,7 @@ export class Ghost implements INodeType {
}
if (post.status === 'scheduled' && post.published_at === undefined) {
throw new NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled');
throw new NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled', { itemIndex: i });
}
responseData = await ghostApiRequest.call(this, 'POST', '/admin/posts', { posts: [post] }, qs);
@@ -320,7 +320,7 @@ export class Ghost implements INodeType {
} else {
const mobileDoc = validateJSON(updateFields.contentJson as string || undefined);
if (mobileDoc === undefined) {
throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON');
throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', { itemIndex: i });
}
post.mobiledoc = updateFields.contentJson;
delete updateFields.contentJson;
@@ -335,7 +335,7 @@ export class Ghost implements INodeType {
}
if (post.status === 'scheduled' && post.published_at === undefined) {
throw new NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled');
throw new NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled', { itemIndex: i });
}
post.updated_at = posts[0].updated_at;