There is a backend service I found in some codebase I'm recently working on and would like to log all the errors with their respective Http statuses if possible get the full stack trace of the errors. Most likely log the errors from this backend service. The next code snippet shows an example of how the backend service is used. This is my first time working with cloud functions
backend.service.ts
import { Injectable } from '@angular/core';
import { AngularFireFunctions } from '@angular/fire/compat/functions';
/**
* Interface with the firebase backend.
*/
@Injectable({ providedIn: 'root' })
export class BackendService
{
constructor(private _fns: AngularFireFunctions) { }
/**
* Call Firebase Cloud Function
*
* @param fName: Function Name
* @param params: Function Parameter Object
*/
callFunction(fName: string, params: any) {
const toCall = this._fns.httpsCallable(fName);
// log errors here
return toCall(params)
}
}
Using backend service
import { Injectable } from '@angular/core';
import { Provision, WriteProvisionCommand } from '@s4y/model/accounting/provisions';
import { BackendService } from '@bxy/utils/ngxfm/angular';
import { DbMethods } from '@bxy/model/data/db';
@Injectable()
export class RequestWithSettlementService
{
constructor(private _backend: BackendService
)
{}
deleteBill = (propId: string, tr: FTransactionRequest) => this.deleteProvision(propId, tr as any as Provision);
deleteProvision(propId: string, tr: FTransactionRequest)
{
const call: WriteProvisionCommand = {
provision: tr,
propId,
method: DbMethods.DELETE
};
return this._backend.callFunction('writeProvision', call);
}
}