Create proper event and util for server-error
Change-Id: Iff4c0bbf0d47edc41b9bd2fb05a2ad9cd2d79767
diff --git a/polygerrit-ui/app/utils/event-util.ts b/polygerrit-ui/app/utils/event-util.ts
index 0af8fe2..56d486d 100644
--- a/polygerrit-ui/app/utils/event-util.ts
+++ b/polygerrit-ui/app/utils/event-util.ts
@@ -15,9 +15,12 @@
* limitations under the License.
*/
+import {FetchRequest} from '../types/types';
+
export enum EventType {
SHOW_ALERT = 'show-alert',
PAGE_ERROR = 'page-error',
+ SERVER_ERROR = 'server-error',
TITLE_CHANGE = 'title-change',
}
@@ -41,6 +44,16 @@
);
}
+export function fireServerError(response: Response, request?: FetchRequest) {
+ document.dispatchEvent(
+ new CustomEvent(EventType.SERVER_ERROR, {
+ detail: {response, request},
+ composed: true,
+ bubbles: true,
+ })
+ );
+}
+
export function fireTitleChange(target: EventTarget, title: string) {
target.dispatchEvent(
new CustomEvent(EventType.TITLE_CHANGE, {