change if/else into observable error handling
authorJane Sandberg <sandbej@linnbenton.edu>
Tue, 26 Mar 2019 22:46:48 +0000 (15:46 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Tue, 26 Mar 2019 22:46:48 +0000 (15:46 -0700)
Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts

index df7ba59..2e149ee 100644 (file)
@@ -76,13 +76,11 @@ export class ManageReservationsComponent implements OnInit {
                 {'barcode' : this.resourceBarcode}, {'limit': 1})
                 .pipe(single())
                 .subscribe((res) => {
-                    if (res.id()) {
-                        this.resourceId = res.id();
-                        this.reservationsGrid.reloadGrid();
-                    } else {
-                        this.resourceId = -1;
-                        this.toast.danger('No resource found with this barcode');
-                    }
+                    this.resourceId = res.id();
+                    this.reservationsGrid.reloadGrid();
+                }, (err) => {
+                    this.resourceId = -1;
+                    this.toast.danger('No resource found with this barcode');
                 });
             }
             this.resourceTypeId = +params.get('resource_type_id');