mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[EC-827] feat: add logging to async actions (#4206)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Directive, HostListener, Input, OnDestroy, Optional } from "@angular/core";
|
||||
import { BehaviorSubject, finalize, Subject, takeUntil, tap } from "rxjs";
|
||||
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { ValidationService } from "@bitwarden/common/abstractions/validation.service";
|
||||
|
||||
import { ButtonLikeAbstraction } from "../shared/button-like.abstraction";
|
||||
@@ -23,7 +24,8 @@ export class BitActionDirective implements OnDestroy {
|
||||
|
||||
constructor(
|
||||
private buttonComponent: ButtonLikeAbstraction,
|
||||
@Optional() private validationService?: ValidationService
|
||||
@Optional() private validationService?: ValidationService,
|
||||
@Optional() private logService?: LogService
|
||||
) {}
|
||||
|
||||
get loading() {
|
||||
@@ -44,7 +46,12 @@ export class BitActionDirective implements OnDestroy {
|
||||
this.loading = true;
|
||||
functionToObservable(this.handler)
|
||||
.pipe(
|
||||
tap({ error: (err: unknown) => this.validationService?.showError(err) }),
|
||||
tap({
|
||||
error: (err: unknown) => {
|
||||
this.logService?.error(`Async action exception: ${err}`);
|
||||
this.validationService?.showError(err);
|
||||
},
|
||||
}),
|
||||
finalize(() => (this.loading = false)),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user