forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass bulkPartialUpdate errors to taskStore.errors (elastic#198606)
Resolves: elastic#198428
- Loading branch information
1 parent
8b31e6a
commit e14ea30
Showing
5 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
x-pack/plugins/task_manager/server/lib/bulk_update_error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export class BulkUpdateError extends Error { | ||
private _statusCode: number; | ||
private _type: string; | ||
|
||
constructor({ | ||
statusCode, | ||
message = 'Bulk update failed with unknown reason', | ||
type, | ||
}: { | ||
statusCode: number; | ||
message?: string; | ||
type: string; | ||
}) { | ||
super(message); | ||
this._statusCode = statusCode; | ||
this._type = type; | ||
} | ||
|
||
public get statusCode() { | ||
return this._statusCode; | ||
} | ||
|
||
public get type() { | ||
return this._type; | ||
} | ||
} | ||
|
||
export function getBulkUpdateStatusCode(error: Error | BulkUpdateError): number | undefined { | ||
if (Boolean(error && error instanceof BulkUpdateError)) { | ||
return (error as BulkUpdateError).statusCode; | ||
} | ||
} | ||
|
||
export function getBulkUpdateErrorType(error: Error | BulkUpdateError): string | undefined { | ||
if (Boolean(error && error instanceof BulkUpdateError)) { | ||
return (error as BulkUpdateError).type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters