How to return an error message from BaseController derived class

Viewed 35

Is there a way of returning a customized error message from BaseController derived class to the client like e.g:

 NotFound("Function :" + scheduleReq.UserFunction + " for date: " + scheduleReq.Date + " already taken");

Unfortunately NotFound return value does not convey my message to the client. I would like to get my message in error variable like below:

Client:

this.accountService.GetScheduleFromPool(this.account.id, schedule)
      .pipe(first())
      .subscribe({
        next: (account) => {
          this.addingSchedule = false;

          console.log(account);
          this.schedules = account.schedules;
          

          if (this.poolElements.length != 0) {
            this.form.get('availableScheduledDate').setValue(this.poolElements[0].date);
            this.form.get('availableFunction').setValue(this.poolElements[0].userFunction);
          }
          this.updateSchedulesAndPoolFromServer();
        },
        error: error => {
          this.addingSchedule = false;

          this.alertService.error(error);
        }
      });
1 Answers

You can extend the functionality of any member class by overwriting it in a derived class of the base class.

Related