Skip to content

Commit

Permalink
throw error with all errorObjects
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Oct 9, 2023
1 parent 03acfe9 commit e2ce999
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,10 @@ export class SavedObjectsRepository {
const { refresh = DEFAULT_REFRESH_SETTING } = options;
const savedObjectsBulkResponse = await this.bulkGet(savedObjects);

const errorObject = savedObjectsBulkResponse.saved_objects.find((obj) => !!obj.error);
if (errorObject) {
throw SavedObjectsErrorHelpers.decorateBadRequestError(new Error(errorObject.error?.message));
const errorObjects = savedObjectsBulkResponse.saved_objects.filter((obj) => !!obj.error);
if (errorObjects && errorObjects.length) {
const errors = errorObjects.map((errorObject) => errorObject.error?.message).join(',');
throw SavedObjectsErrorHelpers.decorateBadRequestError(new Error(errors));
}

// saved objects must exist in specified workspace
Expand Down

0 comments on commit e2ce999

Please sign in to comment.