Stack Exchange
How to get body message in HttpErrorResponse?
I call the service method that makes server request:
 this.applicationBuildingsService
            .create(this.application.appid)
             handleResponseMessage(this.messageService))
            .subscribe((response: Building) => {});

Where handleResponseMessage is:
export const handleResponseMessage = (
    messageService: MessageService,
    message = { success: 'Операция прошла успешно!', error: 'Операция прошла неуспешно!' },
) =>
    pipe(
        tap((response: any) => {
            messageService.showMessage('', response?.message || message.success, 'success');
        }),

        catchError((error: HttpErrorResponse) => {
            console.log(error);
            messageService.showMessage('', error?.message || message.error, 'error');
            return throwError(error);
        }),
    );

Where server returns an error (not 2xx status) I try to get json body from server with message error inside:
 catchError((error: HttpErrorResponse) => {}

But HttpErrorResponse has no body property

Have you checked the documentation (https://angular.io/api/common/http/HttpErrorResponse#error)? Seems like the "error" property holds the error.

Yes, but it returns system error instead body JSON from server

Does the error response contain a JSON object?

Parameter: { observe: 'response' }, let you read the full response including the headers. See the below description:-
Tell HttpClient that you want the full response with the observe option:
getConfigResponse(): Observable<HttpResponse<Config>> {
    return this.http.get<Config>(this.configUrl, { observe: 'response' });
}

