catch events thrown by the acq search API
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 31 Jan 2020 22:22:20 +0000 (17:22 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 31 Jan 2020 22:22:20 +0000 (17:22 -0500)
At present, this does nothing more than indicate to the user
that something went wrong.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts

index e7d1913..bc4d357 100644 (file)
@@ -1,11 +1,13 @@
 import {Injectable} from '@angular/core';
-import {empty} from 'rxjs';
+import {empty, throwError} from 'rxjs';
+import {map} from 'rxjs/operators';
 import {NetService} from '@eg/core/net.service';
 import {AuthService} from '@eg/core/auth.service';
 import {GridDataSource} from '@eg/share/grid/grid';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {Pager} from '@eg/share/util/pager';
 import {IdlObject} from '@eg/core/idl.service';
+import {EventService} from '@eg/core/event.service';
 
 const defaultSearch = {
     lineitem: {
@@ -96,6 +98,7 @@ export class AcqSearchService {
 
     constructor(
         private net: NetService,
+        private evt: EventService,
         private auth: AuthService,
         private pcrud: PcrudService
     ) {
@@ -208,7 +211,6 @@ export class AcqSearchService {
                 }
             });
         });
-        console.debug(andTerms);
         return { andTerms: andTerms, orTerms: orTerms };
     }
 
@@ -241,6 +243,14 @@ export class AcqSearchService {
                         currentSearch.orTerms,
                         null,
                         opts
+                ).pipe(
+                    map(res => {
+                        if (this.evt.parse(res)) {
+                            throw throwError(res);
+                        } else {
+                            return res
+                        }
+                    }),
                 );
             };
         });