From a99030fefe065fd8e9bc5df0048e3750fb8c7d00 Mon Sep 17 00:00:00 2001 From: Rob Fellows Date: Wed, 1 May 2024 15:05:16 -0400 Subject: [PATCH 1/4] [NIFI-13104] - Unknown route handling --- .../main/nifi/src/app/app-routing.module.ts | 7 ++++ .../feature/flow-designer-routing.module.ts | 2 +- .../feature/route-not-found-routing.module.ts | 28 +++++++++++++ .../feature/route-not-found.component.html | 22 +++++++++++ .../feature/route-not-found.component.scss | 20 ++++++++++ .../feature/route-not-found.component.spec.ts | 39 +++++++++++++++++++ .../feature/route-not-found.component.ts | 25 ++++++++++++ .../feature/route-not-found.module.ts | 29 ++++++++++++++ 8 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found-routing.module.ts create mode 100644 nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.html create mode 100644 nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.scss create mode 100644 nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.spec.ts create mode 100644 nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.ts create mode 100644 nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.module.ts diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/app-routing.module.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/app-routing.module.ts index 9415713b81a0..8e38042532b6 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/app-routing.module.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/app-routing.module.ts @@ -18,6 +18,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { authenticationGuard } from './service/guard/authentication.guard'; +import { RouteNotFound } from './pages/route-not-found/feature/route-not-found.component'; const routes: Routes = [ { @@ -101,6 +102,12 @@ const routes: Routes = [ canMatch: [authenticationGuard], loadChildren: () => import('./pages/flow-designer/feature/flow-designer.module').then((m) => m.FlowDesignerModule) + }, + { + path: '**', + component: RouteNotFound, + loadChildren: () => + import('./pages/route-not-found/feature/route-not-found.module').then((m) => m.RouteNotFoundModule) } ]; diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/feature/flow-designer-routing.module.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/feature/flow-designer-routing.module.ts index 5e1c862606eb..374de0962aab 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/feature/flow-designer-routing.module.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/feature/flow-designer-routing.module.ts @@ -52,7 +52,7 @@ const routes: Routes = [ } ] }, - { path: '', component: RootGroupRedirector, canActivate: [rootGroupGuard] } + { path: '', component: RootGroupRedirector, canActivate: [rootGroupGuard], pathMatch: 'full' } ]; @NgModule({ diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found-routing.module.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found-routing.module.ts new file mode 100644 index 000000000000..abf0c7453fe0 --- /dev/null +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found-routing.module.ts @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NgModule } from '@angular/core'; +import { RouteNotFound } from './route-not-found.component'; +import { RouterModule, Routes } from '@angular/router'; + +const routes: Routes = [{ path: '', component: RouteNotFound }]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class RouteNotFoundRoutingModule {} diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.html b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.html new file mode 100644 index 000000000000..d843a77a213a --- /dev/null +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.html @@ -0,0 +1,22 @@ + + +
+ +
The URL entered is not recognized as a supported route.
+
+
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.scss b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.scss new file mode 100644 index 000000000000..1c4f005b2610 --- /dev/null +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.scss @@ -0,0 +1,20 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.error-background { + background: url(../../../../assets/icons/bg-error.png) left top no-repeat; +} diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.spec.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.spec.ts new file mode 100644 index 000000000000..5312b2b67f13 --- /dev/null +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.spec.ts @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RouteNotFound } from './route-not-found.component'; + +describe('RouteNotFound', () => { + let component: RouteNotFound; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [RouteNotFound] + }).compileComponents(); + + fixture = TestBed.createComponent(RouteNotFound); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.ts new file mode 100644 index 000000000000..84fe74e83eaf --- /dev/null +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.component.ts @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Component } from '@angular/core'; + +@Component({ + selector: 'route-not-found', + templateUrl: './route-not-found.component.html', + styleUrl: './route-not-found.component.scss' +}) +export class RouteNotFound {} diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.module.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.module.ts new file mode 100644 index 000000000000..d796c024c02b --- /dev/null +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/route-not-found/feature/route-not-found.module.ts @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NgModule } from '@angular/core'; +import { RouteNotFound } from './route-not-found.component'; +import { CommonModule } from '@angular/common'; +import { RouteNotFoundRoutingModule } from './route-not-found-routing.module'; +import { PageContent } from '../../../ui/common/page-content/page-content.component'; + +@NgModule({ + declarations: [RouteNotFound], + exports: [RouteNotFound], + imports: [CommonModule, RouteNotFoundRoutingModule, PageContent] +}) +export class RouteNotFoundModule {} From 885fea3b26a0b381d78710204f8ebbb7f5ce2c3d Mon Sep 17 00:00:00 2001 From: Rob Fellows Date: Wed, 1 May 2024 16:07:45 -0400 Subject: [PATCH 2/4] Add method to the ErrorHelper that safely gets an error string from an HttpErrorResponse object --- .../access-policy/access-policy.effects.ts | 16 ++++---- .../policy-component.effects.ts | 6 ++- .../state/tenants/tenants.effects.ts | 6 ++- .../cluster-listing.actions.ts | 3 +- .../cluster-listing.effects.ts | 14 ++++--- .../counter-listing.actions.ts | 3 +- .../counter-listing.effects.ts | 8 ++-- ...w-configuration-history-listing.effects.ts | 4 +- .../controller-services.effects.ts | 28 ++++++++++---- .../flow-designer/state/flow/flow.effects.ts | 4 +- .../manage-remote-ports.effects.ts | 6 +-- .../state/parameter/parameter.effects.ts | 14 +++++-- .../parameter-context-listing.effects.ts | 8 ++-- .../state/lineage/lineage.effects.ts | 4 +- .../provenance-event-listing.effects.ts | 24 ++++++++---- .../queue-listing/queue-listing.effects.ts | 10 +++-- .../flow-analysis-rules.effects.ts | 20 ++++++---- .../management-controller-services.effects.ts | 14 ++++--- .../parameter-providers.effects.ts | 6 ++- .../registry-clients.effects.ts | 2 +- .../reporting-tasks.effects.ts | 20 ++++++---- .../component-cluster-status.effects.ts | 8 +++- .../user-listing/user-listing.effects.ts | 38 +++++++++++++++---- .../src/app/service/error-helper.service.ts | 14 +++++++ .../service/property-table-helper.service.ts | 23 +++++++++-- .../nifi/src/app/state/about/about.effects.ts | 6 ++- .../cluster-summary.effects.ts | 18 +++++---- .../component-state.effects.ts | 25 +++++++----- .../extension-types.effects.ts | 13 ++++--- .../flow-configuration.effects.ts | 11 ++++-- .../status-history/status-history.effects.ts | 5 ++- .../system-diagnostics.effects.ts | 31 +++++++-------- 32 files changed, 274 insertions(+), 138 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/access-policy/access-policy.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/access-policy/access-policy.effects.ts index da1aa94c7a66..d3b6d2d87520 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/access-policy/access-policy.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/access-policy/access-policy.effects.ts @@ -37,6 +37,7 @@ import { OverridePolicyDialog } from '../../ui/common/override-policy-dialog/ove import { MEDIUM_DIALOG, SMALL_DIALOG } from '../../../../index'; import { HttpErrorResponse } from '@angular/common/http'; import { loadCurrentUser } from '../../../../state/current-user/current-user.actions'; +import { ErrorHelper } from '../../../../service/error-helper.service'; @Injectable() export class AccessPolicyEffects { @@ -45,7 +46,8 @@ export class AccessPolicyEffects { private store: Store, private router: Router, private accessPoliciesService: AccessPolicyService, - private dialog: MatDialog + private dialog: MatDialog, + private errorHelper: ErrorHelper ) {} setAccessPolicy$ = createEffect(() => @@ -128,7 +130,7 @@ export class AccessPolicyEffects { return of( AccessPolicyActions.accessPolicyApiBannerError({ response: { - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) } }) ); @@ -163,7 +165,7 @@ export class AccessPolicyEffects { of( AccessPolicyActions.accessPolicyApiBannerError({ response: { - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -240,7 +242,7 @@ export class AccessPolicyEffects { of( AccessPolicyActions.accessPolicyApiBannerError({ response: { - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -347,7 +349,7 @@ export class AccessPolicyEffects { of( AccessPolicyActions.accessPolicyApiBannerError({ response: { - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -420,7 +422,7 @@ export class AccessPolicyEffects { of( AccessPolicyActions.accessPolicyApiBannerError({ response: { - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -477,7 +479,7 @@ export class AccessPolicyEffects { of( AccessPolicyActions.accessPolicyApiBannerError({ response: { - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/policy-component/policy-component.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/policy-component/policy-component.effects.ts index c1bdbbd41358..e28c85c867c9 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/policy-component/policy-component.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/policy-component/policy-component.effects.ts @@ -22,12 +22,14 @@ import * as ErrorActions from '../../../../state/error/error.actions'; import { catchError, from, map, of, switchMap } from 'rxjs'; import { AccessPolicyService } from '../../service/access-policy.service'; import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../../../service/error-helper.service'; @Injectable() export class PolicyComponentEffects { constructor( private actions$: Actions, - private accessPoliciesService: AccessPolicyService + private accessPoliciesService: AccessPolicyService, + private errorHelper: ErrorHelper ) {} loadPolicyComponent$ = createEffect(() => @@ -63,7 +65,7 @@ export class PolicyComponentEffects { } else { return of( ErrorActions.snackBarError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/tenants/tenants.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/tenants/tenants.effects.ts index c876c3c46b0d..6d3a152100ee 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/tenants/tenants.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/state/tenants/tenants.effects.ts @@ -22,12 +22,14 @@ import * as ErrorActions from '../../../../state/error/error.actions'; import { catchError, combineLatest, map, of, switchMap } from 'rxjs'; import { AccessPolicyService } from '../../service/access-policy.service'; import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../../../service/error-helper.service'; @Injectable() export class TenantsEffects { constructor( private actions$: Actions, - private accessPoliciesService: AccessPolicyService + private accessPoliciesService: AccessPolicyService, + private errorHelper: ErrorHelper ) {} loadTenants$ = createEffect(() => @@ -46,7 +48,7 @@ export class TenantsEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.snackBarError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.actions.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.actions.ts index 4fdb2bcd5103..de2ebab642ff 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.actions.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.actions.ts @@ -17,6 +17,7 @@ import { createAction, props } from '@ngrx/store'; import { ClusterListingEntity, ClusterNode, ClusterNodeEntity, SelectClusterNodeRequest } from './index'; +import { HttpErrorResponse } from '@angular/common/http'; const CLUSTER_LISTING_PREFIX = '[Cluster Listing]'; @@ -70,7 +71,7 @@ export const removeNodeSuccess = createAction( export const clusterNodeSnackbarError = createAction( `${CLUSTER_LISTING_PREFIX} Cluster Node Snackbar Error`, - props<{ error: string }>() + props<{ errorResponse: HttpErrorResponse }>() ); export const selectClusterNode = createAction( diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.effects.ts index 2173d714ff94..78cbaf0d4456 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/cluster/state/cluster-listing/cluster-listing.effects.ts @@ -110,7 +110,7 @@ export class ClusterListingEffects { return ClusterListingActions.updateNodeSuccess({ response: entity }); }), catchError((errorResponse: HttpErrorResponse) => { - return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error })); + return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse })); }) ) ) @@ -149,7 +149,7 @@ export class ClusterListingEffects { return ClusterListingActions.updateNodeSuccess({ response: entity }); }), catchError((errorResponse: HttpErrorResponse) => { - return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error })); + return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse })); }) ) ) @@ -188,7 +188,7 @@ export class ClusterListingEffects { return ClusterListingActions.updateNodeSuccess({ response: entity }); }), catchError((errorResponse: HttpErrorResponse) => { - return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error })); + return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse })); }) ) ) @@ -227,7 +227,7 @@ export class ClusterListingEffects { return ClusterListingActions.removeNodeSuccess({ response: request }); }), catchError((errorResponse: HttpErrorResponse) => { - return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error })); + return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse })); }) ) ) @@ -319,8 +319,10 @@ export class ClusterListingEffects { clusterNodeSnackbarError$ = createEffect(() => this.actions$.pipe( ofType(ClusterListingActions.clusterNodeSnackbarError), - map((action) => action.error), - switchMap((errorResponse) => of(ErrorActions.snackBarError({ error: errorResponse }))) + map((action) => action.errorResponse), + switchMap((errorResponse) => + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) + ) ) ); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.actions.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.actions.ts index ffa3b9416a3e..b159dde5fcf2 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.actions.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.actions.ts @@ -17,6 +17,7 @@ import { createAction, props } from '@ngrx/store'; import { LoadCounterListingResponse, ResetCounterRequest, ResetCounterSuccess } from './index'; +import { HttpErrorResponse } from '@angular/common/http'; const COUNTER_PREFIX = '[Counter Listing]'; @@ -29,7 +30,7 @@ export const loadCountersSuccess = createAction( export const counterListingApiError = createAction( `${COUNTER_PREFIX} Load Counter Listing Error`, - props<{ error: string }>() + props<{ errorResponse: HttpErrorResponse }>() ); export const promptCounterReset = createAction( diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.effects.ts index 0d06011d6999..25ff6374fd5f 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/counters/state/counter-listing/counter-listing.effects.ts @@ -101,7 +101,7 @@ export class CounterListingEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(CounterListingActions.counterListingApiError({ error: errorResponse.error })) + of(CounterListingActions.counterListingApiError({ errorResponse })) ) ) ) @@ -111,8 +111,10 @@ export class CounterListingEffects { counterListingApiError$ = createEffect(() => this.actions$.pipe( ofType(CounterListingActions.counterListingApiError), - map((action) => action.error), - switchMap((error) => of(ErrorActions.snackBarError({ error }))) + map((action) => action.errorResponse), + switchMap((errorResponse) => + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) + ) ) ); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/state/flow-configuration-history-listing/flow-configuration-history-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/state/flow-configuration-history-listing/flow-configuration-history-listing.effects.ts index 871ec4d66198..3193d69fab85 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/state/flow-configuration-history-listing/flow-configuration-history-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/state/flow-configuration-history-listing/flow-configuration-history-listing.effects.ts @@ -72,7 +72,9 @@ export class FlowConfigurationHistoryListingEffects { this.actions$.pipe( ofType(HistoryActions.flowConfigurationHistorySnackbarError), map((action) => action.errorResponse), - switchMap((errorResponse) => of(ErrorActions.snackBarError({ error: errorResponse.error }))) + switchMap((errorResponse) => + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) + ) ) ); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts index 827d4a97f804..7d1bb6680e22 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts @@ -31,8 +31,8 @@ import { EditControllerService } from '../../../../ui/common/controller-service/ import { ComponentType, ControllerServiceReferencingComponent, - OpenChangeComponentVersionDialogRequest, EditControllerServiceDialogRequest, + OpenChangeComponentVersionDialogRequest, UpdateControllerServiceRequest } from '../../../../state/shared'; import { Router } from '@angular/router'; @@ -153,7 +153,9 @@ export class ControllerServicesEffects { ), catchError((errorResponse: HttpErrorResponse) => { this.dialog.closeAll(); - return of(ErrorActions.snackBarError({ error: errorResponse.error })); + return of( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); }) ) ) @@ -221,7 +223,11 @@ export class ControllerServicesEffects { } }) ); - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }) ) @@ -302,7 +308,11 @@ export class ControllerServicesEffects { goTo(commands, 'Controller Service'); }, error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }); }; @@ -374,7 +384,7 @@ export class ControllerServicesEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ControllerServicesActions.controllerServicesBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -532,7 +542,7 @@ export class ControllerServicesEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(ErrorActions.snackBarError({ error: errorResponse.error })) + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) ) ) ) @@ -574,7 +584,11 @@ export class ControllerServicesEffects { ), tap({ error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts index a8d6206cba7c..8d471b6e4404 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts @@ -3172,7 +3172,7 @@ export class FlowEffects { private bannerOrFullScreenError(errorResponse: HttpErrorResponse) { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return FlowActions.flowBannerError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }); } else { return ErrorActions.fullScreenError(errorResponse.error); @@ -3181,7 +3181,7 @@ export class FlowEffects { private snackBarOrFullScreenError(errorResponse: HttpErrorResponse) { if (this.errorHelper.showErrorInContext(errorResponse.status)) { - return FlowActions.flowSnackbarError({ error: errorResponse.error }); + return FlowActions.flowSnackbarError({ error: this.errorHelper.getErrorString(errorResponse) }); } else { return ErrorActions.fullScreenError(errorResponse.error); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/manage-remote-ports/manage-remote-ports.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/manage-remote-ports/manage-remote-ports.effects.ts index cd3649f1ef15..656fd0dbf3cc 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/manage-remote-ports/manage-remote-ports.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/manage-remote-ports/manage-remote-ports.effects.ts @@ -152,7 +152,7 @@ export class ManageRemotePortsEffects { }); }), catchError((errorResponse: HttpErrorResponse) => - of(ErrorActions.snackBarError({ error: errorResponse.error })) + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) ) ); }) @@ -181,7 +181,7 @@ export class ManageRemotePortsEffects { }); }), catchError((errorResponse: HttpErrorResponse) => - of(ErrorActions.snackBarError({ error: errorResponse.error })) + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) ) ); }) @@ -255,7 +255,7 @@ export class ManageRemotePortsEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ManageRemotePortsActions.remotePortsBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts index 9413370b2fab..1e3ea53cfe5b 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts @@ -26,13 +26,15 @@ import { isDefinedAndNotNull, ParameterContextUpdateRequest } from '../../../../ import { selectUpdateRequest } from './parameter.selectors'; import { ParameterService } from '../../service/parameter.service'; import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../../../service/error-helper.service'; @Injectable() export class ParameterEffects { constructor( private actions$: Actions, private store: Store, - private parameterService: ParameterService + private parameterService: ParameterService, + private errorHelper: ErrorHelper ) {} submitParameterContextUpdateRequest$ = createEffect(() => @@ -49,7 +51,11 @@ export class ParameterEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(ParameterActions.parameterApiError({ error: errorResponse.error })) + of( + ParameterActions.parameterApiError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ) ) ) ) @@ -99,7 +105,7 @@ export class ParameterEffects { catchError((errorResponse: HttpErrorResponse) => of( ParameterActions.parameterApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -135,7 +141,7 @@ export class ParameterEffects { catchError((errorResponse: HttpErrorResponse) => of( ParameterActions.parameterApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts index 058396d8da72..e9fd4f330ed0 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts @@ -161,7 +161,7 @@ export class ParameterContextListingEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ParameterContextListingActions.parameterContextListingBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -230,7 +230,7 @@ export class ParameterContextListingEffects { this.router.navigate(['/parameter-contexts']); return of( ParameterContextListingActions.parameterContextListingSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); }) @@ -362,7 +362,7 @@ export class ParameterContextListingEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ParameterContextListingActions.parameterContextListingBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -425,7 +425,7 @@ export class ParameterContextListingEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ParameterContextListingActions.parameterContextListingBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/lineage/lineage.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/lineage/lineage.effects.ts index 7a4be5a54f94..17265de04f55 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/lineage/lineage.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/lineage/lineage.effects.ts @@ -58,7 +58,7 @@ export class LineageEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( LineageActions.lineageApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -120,7 +120,7 @@ export class LineageEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( LineageActions.lineageApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/provenance-event-listing/provenance-event-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/provenance-event-listing/provenance-event-listing.effects.ts index 8fbcd610ecc3..e051f5fbfd01 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/provenance-event-listing/provenance-event-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/provenance/state/provenance-event-listing/provenance-event-listing.effects.ts @@ -27,8 +27,8 @@ import { Router } from '@angular/router'; import { OkDialog } from '../../../../ui/common/ok-dialog/ok-dialog.component'; import { ProvenanceService } from '../../service/provenance.service'; import { - selectClusterNodeIdFromActiveProvenance, selectActiveProvenanceId, + selectClusterNodeIdFromActiveProvenance, selectProvenanceOptions, selectProvenanceRequest, selectTimeOffset @@ -113,7 +113,7 @@ export class ProvenanceEventListingEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ProvenanceEventListingActions.provenanceApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -185,7 +185,7 @@ export class ProvenanceEventListingEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ProvenanceEventListingActions.provenanceApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -248,7 +248,7 @@ export class ProvenanceEventListingEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(ErrorActions.snackBarError({ error: errorResponse.error })) + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) ) ); } else { @@ -371,7 +371,9 @@ export class ProvenanceEventListingEffects { }, error: (errorResponse: HttpErrorResponse) => { this.store.dispatch( - ErrorActions.snackBarError({ error: errorResponse.error }) + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) ); } }); @@ -379,7 +381,11 @@ export class ProvenanceEventListingEffects { }, error: (errorResponse: HttpErrorResponse) => { if (this.errorHelper.showErrorInContext(errorResponse.status)) { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } else { this.store.dispatch(this.errorHelper.fullScreenError(errorResponse)); } @@ -403,7 +409,11 @@ export class ProvenanceEventListingEffects { this.router.navigate(this.getEventComponentLink(event.groupId, event.componentId)); }, error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }); } else if (request.groupId && request.componentId) { diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/queue/state/queue-listing/queue-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/queue/state/queue-listing/queue-listing.effects.ts index 23be38912ec7..aca3719b0e09 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/queue/state/queue-listing/queue-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/queue/state/queue-listing/queue-listing.effects.ts @@ -113,7 +113,7 @@ export class QueueListingEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( QueueListingActions.queueListingApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -181,7 +181,7 @@ export class QueueListingEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( QueueListingActions.queueListingApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -221,7 +221,9 @@ export class QueueListingEffects { if (listingRequest) { this.queueService.deleteQueueListingRequest(listingRequest).subscribe({ error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); } }); } @@ -247,7 +249,7 @@ export class QueueListingEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.snackBarError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/flow-analysis-rules/flow-analysis-rules.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/flow-analysis-rules/flow-analysis-rules.effects.ts index 01b07b631ea8..ff95464c17f9 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/flow-analysis-rules/flow-analysis-rules.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/flow-analysis-rules/flow-analysis-rules.effects.ts @@ -111,7 +111,9 @@ export class FlowAnalysisRulesEffects { catchError((errorResponse: HttpErrorResponse) => { this.dialog.closeAll(); return of( - FlowAnalysisRuleActions.flowAnalysisRuleSnackbarApiError({ error: errorResponse.error }) + FlowAnalysisRuleActions.flowAnalysisRuleSnackbarApiError({ + error: this.errorHelper.getErrorString(errorResponse) + }) ); }) ) @@ -196,7 +198,7 @@ export class FlowAnalysisRulesEffects { catchError((errorResponse: HttpErrorResponse) => of( FlowAnalysisRuleActions.flowAnalysisRuleSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -241,7 +243,7 @@ export class FlowAnalysisRulesEffects { ); this.store.dispatch( FlowAnalysisRuleActions.flowAnalysisRuleSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } @@ -349,7 +351,7 @@ export class FlowAnalysisRulesEffects { catchError((errorResponse: HttpErrorResponse) => of( FlowAnalysisRuleActions.flowAnalysisRuleBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -405,7 +407,7 @@ export class FlowAnalysisRulesEffects { catchError((errorResponse: HttpErrorResponse) => of( FlowAnalysisRuleActions.flowAnalysisRuleSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -446,7 +448,7 @@ export class FlowAnalysisRulesEffects { catchError((errorResponse: HttpErrorResponse) => of( FlowAnalysisRuleActions.flowAnalysisRuleSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -487,7 +489,11 @@ export class FlowAnalysisRulesEffects { ), tap({ error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/management-controller-services/management-controller-services.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/management-controller-services/management-controller-services.effects.ts index 75db657758f5..806e84e2f9e8 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/management-controller-services/management-controller-services.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/management-controller-services/management-controller-services.effects.ts @@ -137,7 +137,7 @@ export class ManagementControllerServicesEffects { this.dialog.closeAll(); return of( ManagementControllerServicesActions.managementControllerServicesSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); }) @@ -213,7 +213,7 @@ export class ManagementControllerServicesEffects { ); this.store.dispatch( ManagementControllerServicesActions.managementControllerServicesSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } @@ -341,7 +341,7 @@ export class ManagementControllerServicesEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ManagementControllerServicesActions.managementControllerServicesBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { @@ -495,7 +495,7 @@ export class ManagementControllerServicesEffects { catchError((errorResponse: HttpErrorResponse) => of( ManagementControllerServicesActions.managementControllerServicesSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -534,7 +534,11 @@ export class ManagementControllerServicesEffects { ), tap({ error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts index b38757e01951..113a8750ea3b 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts @@ -284,7 +284,11 @@ export class ParameterProvidersEffects { } }) ); - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts index 8ec24df3b7c3..1e60d7cc190b 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts @@ -117,7 +117,7 @@ export class RegistryClientsEffects { this.dialog.closeAll(); return of( RegistryClientsActions.registryClientsSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); }) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/reporting-tasks/reporting-tasks.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/reporting-tasks/reporting-tasks.effects.ts index 66e0c5a260ef..1e5599776fb3 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/reporting-tasks/reporting-tasks.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/reporting-tasks/reporting-tasks.effects.ts @@ -112,7 +112,7 @@ export class ReportingTasksEffects { this.dialog.closeAll(); return of( ReportingTaskActions.reportingTasksSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ); }) @@ -198,7 +198,7 @@ export class ReportingTasksEffects { catchError((errorResponse: HttpErrorResponse) => of( ReportingTaskActions.reportingTasksSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -254,7 +254,9 @@ export class ReportingTasksEffects { }) ); this.store.dispatch( - ReportingTaskActions.reportingTasksSnackbarApiError({ error: errorResponse.error }) + ReportingTaskActions.reportingTasksSnackbarApiError({ + error: this.errorHelper.getErrorString(errorResponse) + }) ); } }) @@ -361,7 +363,7 @@ export class ReportingTasksEffects { catchError((errorResponse: HttpErrorResponse) => of( ReportingTaskActions.reportingTasksBannerApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -403,7 +405,7 @@ export class ReportingTasksEffects { catchError((errorResponse: HttpErrorResponse) => of( ReportingTaskActions.reportingTasksSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -428,7 +430,7 @@ export class ReportingTasksEffects { catchError((errorResponse: HttpErrorResponse) => of( ReportingTaskActions.reportingTasksSnackbarApiError({ - error: errorResponse.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -465,7 +467,11 @@ export class ReportingTasksEffects { ), tap({ error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/summary/state/component-cluster-status/component-cluster-status.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/summary/state/component-cluster-status/component-cluster-status.effects.ts index 2002e827fc18..56f69441d911 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/summary/state/component-cluster-status/component-cluster-status.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/summary/state/component-cluster-status/component-cluster-status.effects.ts @@ -58,7 +58,9 @@ export class ComponentClusterStatusEffects { }), catchError((errorResponse: HttpErrorResponse) => { if (this.errorHelper.showErrorInContext(errorResponse.status)) { - return of(ErrorActions.snackBarError({ error: errorResponse.error })); + return of( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); } return of(this.errorHelper.fullScreenError(errorResponse)); }) @@ -83,7 +85,9 @@ export class ComponentClusterStatusEffects { }), catchError((errorResponse: HttpErrorResponse) => { if (this.errorHelper.showErrorInContext(errorResponse.status)) { - return of(ErrorActions.snackBarError({ error: errorResponse.error })); + return of( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); } return of(this.errorHelper.fullScreenError(errorResponse)); }) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/users/state/user-listing/user-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/users/state/user-listing/user-listing.effects.ts index d114a460f6b2..5cfc638a4059 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/users/state/user-listing/user-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/users/state/user-listing/user-listing.effects.ts @@ -22,6 +22,7 @@ import { NiFiState } from '../../../../state'; import { Store } from '@ngrx/store'; import { Router } from '@angular/router'; import * as UserListingActions from './user-listing.actions'; +import { selectTenant } from './user-listing.actions'; import { catchError, combineLatest, filter, from, map, mergeMap, of, switchMap, take, takeUntil, tap } from 'rxjs'; import { MatDialog } from '@angular/material/dialog'; import { UsersService } from '../../service/users.service'; @@ -29,7 +30,6 @@ import { YesNoDialog } from '../../../../ui/common/yes-no-dialog/yes-no-dialog.c import { EditTenantDialog } from '../../../../ui/common/edit-tenant/edit-tenant-dialog.component'; import { selectSaving, selectStatus, selectUserGroups, selectUsers } from './user-listing.selectors'; import { EditTenantRequest, UserGroupEntity } from '../../../../state/shared'; -import { selectTenant } from './user-listing.actions'; import { Client } from '../../../../service/client.service'; import { NiFiCommon } from '../../../../service/nifi-common.service'; import { UserAccessPolicies } from '../../ui/user-listing/user-access-policies/user-access-policies.component'; @@ -160,7 +160,11 @@ export class UserListingEffects { ), catchError((errorResponse: HttpErrorResponse) => { this.dialog.closeAll(); - return of(UserListingActions.usersApiSnackbarError({ error: errorResponse.error })); + return of( + UserListingActions.usersApiSnackbarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); }) ) ) @@ -287,7 +291,11 @@ export class UserListingEffects { ), catchError((errorResponse: HttpErrorResponse) => { this.dialog.closeAll(); - return of(UserListingActions.usersApiSnackbarError({ error: errorResponse.error })); + return of( + UserListingActions.usersApiSnackbarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); }) ) ) @@ -413,7 +421,11 @@ export class UserListingEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(UserListingActions.usersApiBannerError({ error: errorResponse.error })) + of( + UserListingActions.usersApiBannerError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ) ) ) ) @@ -617,7 +629,11 @@ export class UserListingEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(UserListingActions.usersApiBannerError({ error: errorResponse.error })) + of( + UserListingActions.usersApiBannerError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ) ) ) ) @@ -708,7 +724,11 @@ export class UserListingEffects { from(this.usersService.deleteUser(request.user)).pipe( map(() => UserListingActions.loadTenants()), catchError((errorResponse: HttpErrorResponse) => - of(UserListingActions.usersApiSnackbarError({ error: errorResponse.error })) + of( + UserListingActions.usersApiSnackbarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ) ) ) ) @@ -749,7 +769,11 @@ export class UserListingEffects { from(this.usersService.deleteUserGroup(request.userGroup)).pipe( map(() => UserListingActions.loadTenants()), catchError((errorResponse: HttpErrorResponse) => - of(UserListingActions.usersApiSnackbarError({ error: errorResponse.error })) + of( + UserListingActions.usersApiSnackbarError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ) ) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts index 16976ee041ed..2893b0b9be8f 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts @@ -78,4 +78,18 @@ export class ErrorHelper { return this.fullScreenError(errorResponse); } } + + getErrorString(errorResponse: HttpErrorResponse, prefix?: string): string { + let errorMessage = 'An unspecified error occurred.'; + if (errorResponse.error && errorResponse.status !== 0) { + errorMessage = errorResponse.error; + } else if (!errorResponse.error && errorResponse.status !== 0) { + errorMessage = errorResponse.message || `${errorResponse.status}`; + } + if (prefix) { + return `${prefix} - [${errorMessage}]`; + } else { + return errorMessage; + } + } } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts index 8d8f2417a30b..9947ad983afa 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts @@ -40,6 +40,7 @@ import { Store } from '@ngrx/store'; import { snackBarError } from '../state/error/error.actions'; import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { LARGE_DIALOG, SMALL_DIALOG } from '../index'; +import { ErrorHelper } from './error-helper.service'; @Injectable({ providedIn: 'root' @@ -52,7 +53,8 @@ export class PropertyTableHelperService { private dialog: MatDialog, private store: Store, private extensionTypesService: ExtensionTypesService, - private client: Client + private client: Client, + private errorHelper: ErrorHelper ) {} getComponentHistory(componentId: string): Observable { @@ -85,7 +87,14 @@ export class PropertyTableHelperService { .pipe( take(1), catchError((errorResponse: HttpErrorResponse) => { - this.store.dispatch(snackBarError({ error: errorResponse.error })); + this.store.dispatch( + snackBarError({ + error: this.errorHelper.getErrorString( + errorResponse, + `Failed to get property descriptor for ${dialogResponse.name}.` + ) + }) + ); // handle the error here to keep the observable alive so the // user can attempt to create the property again @@ -172,7 +181,10 @@ export class PropertyTableHelperService { catchError((errorResponse: HttpErrorResponse) => { this.store.dispatch( snackBarError({ - error: `Unable to create new Service: ${errorResponse.error}` + error: this.errorHelper.getErrorString( + errorResponse, + `Unable to create new Service.` + ) }) ); @@ -200,7 +212,10 @@ export class PropertyTableHelperService { this.store.dispatch( snackBarError({ - error: `Service created but unable to reload Property Descriptor: ${errorResponse.error}` + error: this.errorHelper.getErrorString( + errorResponse, + 'Service created but unable to reload Property Descriptor.' + ) }) ); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/about/about.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/about/about.effects.ts index 2661061cd068..a762820493f4 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/about/about.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/about/about.effects.ts @@ -25,13 +25,15 @@ import { HttpErrorResponse } from '@angular/common/http'; import { MatDialog } from '@angular/material/dialog'; import { AboutDialog } from '../../ui/common/about-dialog/about-dialog.component'; import { MEDIUM_DIALOG } from '../../index'; +import { ErrorHelper } from '../../service/error-helper.service'; @Injectable() export class AboutEffects { constructor( private actions$: Actions, private aboutService: AboutService, - private dialog: MatDialog + private dialog: MatDialog, + private errorHelper: ErrorHelper ) {} loadAbout$ = createEffect(() => @@ -46,7 +48,7 @@ export class AboutEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(ErrorActions.snackBarError({ error: errorResponse.error })) + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) ) ) ); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/cluster-summary/cluster-summary.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/cluster-summary/cluster-summary.effects.ts index 00cf528a8af3..3ce3627efc8d 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/cluster-summary/cluster-summary.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/cluster-summary/cluster-summary.effects.ts @@ -31,6 +31,7 @@ import * as ErrorActions from '../error/error.actions'; import { OkDialog } from '../../ui/common/ok-dialog/ok-dialog.component'; import { MEDIUM_DIALOG } from '../../index'; import { MatDialog } from '@angular/material/dialog'; +import { ErrorHelper } from '../../service/error-helper.service'; @Injectable() export class ClusterSummaryEffects { @@ -38,7 +39,8 @@ export class ClusterSummaryEffects { private actions$: Actions, private clusterService: ClusterService, private store: Store, - private dialog: MatDialog + private dialog: MatDialog, + private errorHelper: ErrorHelper ) {} loadClusterSummary$ = createEffect(() => @@ -69,9 +71,10 @@ export class ClusterSummaryEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.snackBarError({ - error: `Failed to load cluster summary - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + 'Failed to load cluster summary' + ) }) ) ) @@ -148,9 +151,10 @@ export class ClusterSummaryEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.snackBarError({ - error: `Failed to search cluster summary - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + 'Failed to search cluster summary' + ) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/component-state/component-state.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/component-state/component-state.effects.ts index fa1ebd0886c5..50fdc864264c 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/component-state/component-state.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/component-state/component-state.effects.ts @@ -31,6 +31,7 @@ import { isDefinedAndNotNull } from '../shared'; import { LARGE_DIALOG } from '../../index'; import * as ErrorActions from '../error/error.actions'; import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../service/error-helper.service'; @Injectable() export class ComponentStateEffects { @@ -38,7 +39,8 @@ export class ComponentStateEffects { private actions$: Actions, private store: Store, private componentStateService: ComponentStateService, - private dialog: MatDialog + private dialog: MatDialog, + private errorHelper: ErrorHelper ) {} getComponentStateAndOpenDialog$ = createEffect(() => @@ -58,9 +60,10 @@ export class ComponentStateEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.snackBarError({ - error: `Failed to get the component state for ${request.componentName}. - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + `Failed to get the component state for ${request.componentName}.` + ) }) ) ) @@ -106,9 +109,10 @@ export class ComponentStateEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.addBannerError({ - error: `Failed to clear the component state. - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + 'Failed to clear the component state.' + ) }) ) ) @@ -135,9 +139,10 @@ export class ComponentStateEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.addBannerError({ - error: `Failed to reload the component state. - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + 'Failed to reload the component state.' + ) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/extension-types/extension-types.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/extension-types/extension-types.effects.ts index 3622c1fb2e89..5c2f6bd9701d 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/extension-types/extension-types.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/extension-types/extension-types.effects.ts @@ -22,12 +22,14 @@ import { catchError, combineLatest, map, of, switchMap } from 'rxjs'; import { ExtensionTypesService } from '../../service/extension-types.service'; import * as ErrorActions from '../error/error.actions'; import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../service/error-helper.service'; @Injectable() export class ExtensionTypesEffects { constructor( private actions$: Actions, - private extensionTypesService: ExtensionTypesService + private extensionTypesService: ExtensionTypesService, + private errorHelper: ErrorHelper ) {} loadExtensionTypesForCanvas$ = createEffect(() => @@ -119,7 +121,7 @@ export class ExtensionTypesEffects { }) ), catchError((errorResponse: HttpErrorResponse) => - of(ExtensionTypesActions.extensionTypesApiError({ error: errorResponse.error })) + of(ExtensionTypesActions.extensionTypesApiError({ error: errorResponse })) ) ) ) @@ -133,9 +135,10 @@ export class ExtensionTypesEffects { switchMap((errorResponse: HttpErrorResponse) => of( ErrorActions.snackBarError({ - error: `Failed to load extension types. You may not be able to create new Processors, Controller Services, Reporting Tasks, Parameter Providers, or Flow Analysis Rules. - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + 'Failed to load extension types. You may not be able to create new Processors, Controller Services, Reporting Tasks, Parameter Providers, or Flow Analysis Rules.' + ) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/flow-configuration/flow-configuration.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/flow-configuration/flow-configuration.effects.ts index 8d48654c516a..7060ff9c1255 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/flow-configuration/flow-configuration.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/flow-configuration/flow-configuration.effects.ts @@ -22,12 +22,14 @@ import { catchError, from, map, of, switchMap } from 'rxjs'; import { FlowConfigurationService } from '../../service/flow-configuration.service'; import * as ErrorActions from '../error/error.actions'; import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../service/error-helper.service'; @Injectable() export class FlowConfigurationEffects { constructor( private actions$: Actions, - private flowConfigurationService: FlowConfigurationService + private flowConfigurationService: FlowConfigurationService, + private errorHelper: ErrorHelper ) {} loadFlowConfiguration$ = createEffect(() => @@ -44,9 +46,10 @@ export class FlowConfigurationEffects { catchError((errorResponse: HttpErrorResponse) => of( ErrorActions.snackBarError({ - error: `Failed to load Flow Configuration. - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + 'Failed to load Flow Configuration.' + ) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts index 22b0018bd386..1599f868fe9b 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts @@ -205,7 +205,8 @@ export class StatusHistoryEffects { private bannerOrFullScreenError(errorResponse: HttpErrorResponse) { if (this.errorHelper.showErrorInContext(errorResponse.status)) { - const error = `Failed to reload Status History. - [${errorResponse.error || errorResponse.status}]`; + const error = this.errorHelper.getErrorString(errorResponse, 'Failed to reload Status History.'); + return of(StatusHistoryActions.statusHistoryBannerError({ error })); } else { return of(ErrorActions.fullScreenError(errorResponse.error)); @@ -214,7 +215,7 @@ export class StatusHistoryEffects { private snackBarOrFullScreenError(errorResponse: HttpErrorResponse) { if (this.errorHelper.showErrorInContext(errorResponse.status)) { - const error = `Failed to load Status History. - [${errorResponse.error || errorResponse.status}]`; + const error = this.errorHelper.getErrorString(errorResponse, 'Failed to load Status History.'); return of(ErrorActions.snackBarError({ error })); } else { return of(ErrorActions.fullScreenError(errorResponse.error)); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/system-diagnostics/system-diagnostics.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/system-diagnostics/system-diagnostics.effects.ts index 77fe2efb7c9a..9c2ba8918f96 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/system-diagnostics/system-diagnostics.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/system-diagnostics/system-diagnostics.effects.ts @@ -28,6 +28,7 @@ import { SystemDiagnosticsDialog } from '../../ui/common/system-diagnostics-dial import { LARGE_DIALOG } from '../../index'; import * as ErrorActions from '../error/error.actions'; import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../service/error-helper.service'; @Injectable() export class SystemDiagnosticsEffects { @@ -35,7 +36,8 @@ export class SystemDiagnosticsEffects { private actions$: Actions, private store: Store, private systemDiagnosticsService: SystemDiagnosticsService, - private dialog: MatDialog + private dialog: MatDialog, + private errorHelper: ErrorHelper ) {} reloadSystemDiagnostics$ = createEffect(() => @@ -52,22 +54,14 @@ export class SystemDiagnosticsEffects { }) ), catchError((errorResponse: HttpErrorResponse) => { + const error = this.errorHelper.getErrorString( + errorResponse, + 'Failed to reload System Diagnostics.' + ); if (request.errorStrategy === 'snackbar') { - return of( - SystemDiagnosticsActions.systemDiagnosticsSnackbarError({ - error: `Failed to reload System Diagnostics. - [${ - errorResponse.error || errorResponse.status - }]` - }) - ); + return of(SystemDiagnosticsActions.systemDiagnosticsSnackbarError({ error })); } - return of( - SystemDiagnosticsActions.systemDiagnosticsBannerError({ - error: `Failed to reload System Diagnostics. - [${ - errorResponse.error || errorResponse.status - }]` - }) - ); + return of(SystemDiagnosticsActions.systemDiagnosticsBannerError({ error })); }) ) ) @@ -90,9 +84,10 @@ export class SystemDiagnosticsEffects { catchError((errorResponse: HttpErrorResponse) => of( SystemDiagnosticsActions.systemDiagnosticsSnackbarError({ - error: `Failed to load System Diagnostics. - [${ - errorResponse.error || errorResponse.status - }]` + error: this.errorHelper.getErrorString( + errorResponse, + 'Failed to load System Diagnostics.' + ) }) ) ) From 1f84e744b9bfba24e24f460008134d00d7495a83 Mon Sep 17 00:00:00 2001 From: Rob Fellows Date: Thu, 2 May 2024 09:34:52 -0400 Subject: [PATCH 3/4] review feedback --- .../service/parameter-helper.service.ts | 12 +++++-- ...ler-service-advanced-ui-params.resolver.ts | 4 ++- .../processor-advanced-ui-params.resolver.ts | 4 ++- .../flow-designer/state/flow/flow.effects.ts | 2 +- .../state/queue/queue.effects.ts | 17 +++++---- .../login/state/access/access.effects.ts | 17 +++++---- .../parameter-context-listing.effects.ts | 4 +-- ...ler-service-advanced-ui-params.resolver.ts | 4 ++- ...er-provider-advanced-ui-params.resolver.ts | 4 ++- ...orting-task-advanced-ui-params.resolver.ts | 4 ++- .../settings/state/general/general.effects.ts | 4 +-- .../parameter-providers.effects.ts | 36 +++++++++++-------- .../registry-clients.effects.ts | 8 ++--- .../src/app/service/error-helper.service.ts | 10 +++--- .../service/property-table-helper.service.ts | 4 ++- .../controller-service-state.effects.ts | 21 ++++++----- 16 files changed, 96 insertions(+), 59 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/parameter-helper.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/parameter-helper.service.ts index 08dc0af1c729..fad0378e4e09 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/parameter-helper.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/parameter-helper.service.ts @@ -32,6 +32,7 @@ import * as ParameterActions from '../state/parameter/parameter.actions'; import { FlowService } from './flow.service'; import { MEDIUM_DIALOG } from '../../../index'; import { ClusterConnectionService } from '../../../service/cluster-connection.service'; +import { ErrorHelper } from '../../../service/error-helper.service'; @Injectable({ providedIn: 'root' @@ -43,7 +44,8 @@ export class ParameterHelperService { private flowService: FlowService, private parameterService: ParameterService, private clusterConnectionService: ClusterConnectionService, - private client: Client + private client: Client, + private errorHelper: ErrorHelper ) {} /** @@ -56,7 +58,9 @@ export class ParameterHelperService { return this.flowService.getParameterContext(parameterContextId).pipe( take(1), catchError((errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); // consider the error handled and allow the user to reattempt the action return EMPTY; @@ -82,7 +86,9 @@ export class ParameterHelperService { return (name: string, sensitive: boolean, value: string | null) => { return this.parameterService.getParameterContext(parameterContextId, false).pipe( catchError((errorResponse: HttpErrorResponse) => { - this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + this.store.dispatch( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); // consider the error handled and allow the user to reattempt the action return EMPTY; diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/resolver/controller-service-advanced-ui-params.resolver.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/resolver/controller-service-advanced-ui-params.resolver.ts index 9abc02c9afd2..91f2d6721d00 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/resolver/controller-service-advanced-ui-params.resolver.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/resolver/controller-service-advanced-ui-params.resolver.ts @@ -27,6 +27,7 @@ import { ControllerServiceService } from '../controller-service.service'; import { HttpErrorResponse } from '@angular/common/http'; import { fullScreenError } from '../../../../state/error/error.actions'; import { ClusterConnectionService } from '../../../../service/cluster-connection.service'; +import { ErrorHelper } from '../../../../service/error-helper.service'; export const controllerServiceAdvancedUiParamsResolver: ResolveFn = ( route: ActivatedRouteSnapshot @@ -35,6 +36,7 @@ export const controllerServiceAdvancedUiParamsResolver: ResolveFn = (route: ActivatedRouteSnapshot) => { const store: Store = inject(Store); const flowService: FlowService = inject(FlowService); const client: Client = inject(Client); const clusterConnectionService: ClusterConnectionService = inject(ClusterConnectionService); + const errorHelper: ErrorHelper = inject(ErrorHelper); // getting id parameter from activated route because ngrx router store // is not initialized when this resolver executes @@ -52,7 +54,7 @@ export const processorAdvancedUiParamsResolver: ResolveFn = (r fullScreenError({ errorDetail: { title: 'Unable to Open Advanced UI', - message: errorResponse.error + message: errorHelper.getErrorString(errorResponse) } }) ); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts index 8d471b6e4404..e546e60e0d10 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts @@ -2431,7 +2431,7 @@ export class FlowEffects { this.store.dispatch( FlowActions.showOkDialog({ title: 'Failed to Replay Event', - message: errorResponse.error + message: this.errorHelper.getErrorString(errorResponse) }) ); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts index b4cd6b947b77..c8bdeb43794e 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts @@ -33,6 +33,8 @@ import { OkDialog } from '../../../../ui/common/ok-dialog/ok-dialog.component'; import { loadConnection, loadProcessGroup } from '../flow/flow.actions'; import { resetQueueState } from './queue.actions'; import { SMALL_DIALOG } from '../../../../index'; +import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../../../service/error-helper.service'; @Injectable() export class QueueEffects { @@ -40,7 +42,8 @@ export class QueueEffects { private actions$: Actions, private store: Store, private queueService: QueueService, - private dialog: MatDialog + private dialog: MatDialog, + private errorHelper: ErrorHelper ) {} promptEmptyQueueRequest$ = createEffect( @@ -95,10 +98,10 @@ export class QueueEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( QueueActions.queueApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -159,10 +162,10 @@ export class QueueEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( QueueActions.queueApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -211,10 +214,10 @@ export class QueueEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( QueueActions.queueApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/login/state/access/access.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/login/state/access/access.effects.ts index 24dc3937ba2c..dedb73a94540 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/login/state/access/access.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/login/state/access/access.effects.ts @@ -25,6 +25,8 @@ import { Router } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; import { OkDialog } from '../../../../ui/common/ok-dialog/ok-dialog.component'; import { MEDIUM_DIALOG } from '../../../../index'; +import { ErrorHelper } from '../../../../service/error-helper.service'; +import { HttpErrorResponse } from '@angular/common/http'; @Injectable() export class AccessEffects { @@ -33,7 +35,8 @@ export class AccessEffects { private authService: AuthService, private authStorage: AuthStorage, private router: Router, - private dialog: MatDialog + private dialog: MatDialog, + private errorHelper: ErrorHelper ) {} loadAccess$ = createEffect(() => @@ -49,12 +52,12 @@ export class AccessEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( AccessActions.accessApiError({ error: { title: 'Unable to check Access Status', - message: error.error + message: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -77,7 +80,9 @@ export class AccessEffects { } return AccessActions.verifyAccess(); }), - catchError((error) => of(AccessActions.loginFailure({ failure: error.error }))) + catchError((errorResponse: HttpErrorResponse) => + of(AccessActions.loginFailure({ failure: this.errorHelper.getErrorString(errorResponse) })) + ) ) ) ) @@ -118,12 +123,12 @@ export class AccessEffects { }); } }), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( AccessActions.accessApiError({ error: { title: 'Unable to log in', - message: error.error + message: this.errorHelper.getErrorString(errorResponse) } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts index e9fd4f330ed0..6318c282a891 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts @@ -514,10 +514,10 @@ export class ParameterContextListingEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( ParameterContextListingActions.parameterContextListingSnackbarApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/service/resolver/controller-service-advanced-ui-params.resolver.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/service/resolver/controller-service-advanced-ui-params.resolver.ts index 2d97fb6913e9..6ca955cc5b8a 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/service/resolver/controller-service-advanced-ui-params.resolver.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/service/resolver/controller-service-advanced-ui-params.resolver.ts @@ -27,6 +27,7 @@ import { fullScreenError } from '../../../../state/error/error.actions'; import { ManagementControllerServiceService } from '../management-controller-service.service'; import { selectService } from '../../state/management-controller-services/management-controller-services.selectors'; import { ClusterConnectionService } from '../../../../service/cluster-connection.service'; +import { ErrorHelper } from '../../../../service/error-helper.service'; export const controllerServiceAdvancedUiParamsResolver: ResolveFn = ( route: ActivatedRouteSnapshot @@ -37,6 +38,7 @@ export const controllerServiceAdvancedUiParamsResolver: ResolveFn = ( route: ActivatedRouteSnapshot @@ -35,6 +36,7 @@ export const parameterProviderAdvancedUiParamsResolver: ResolveFn = (route: ActivatedRouteSnapshot) => { const store: Store = inject(Store); const reportingTaskService: ReportingTaskService = inject(ReportingTaskService); const client: Client = inject(Client); const clusterConnectionService: ClusterConnectionService = inject(ClusterConnectionService); + const errorHelper: ErrorHelper = inject(ErrorHelper); // getting id parameter from activated route because ngrx router store // is not initialized when this resolver executes @@ -52,7 +54,7 @@ export const reportingTaskAdvancedUiParamsResolver: ResolveFn fullScreenError({ errorDetail: { title: 'Unable to Open Advanced UI', - message: errorResponse.error + message: errorHelper.getErrorString(errorResponse) } }) ); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/general/general.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/general/general.effects.ts index c19b3d0f0af7..2e71b3f4ad38 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/general/general.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/general/general.effects.ts @@ -75,10 +75,10 @@ export class GeneralEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( GeneralActions.controllerConfigApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts index 113a8750ea3b..1340fb66bd93 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts @@ -153,9 +153,11 @@ export class ParameterProvidersEffects { } }) ), - catchError((error: HttpErrorResponse) => { + catchError((errorResponse: HttpErrorResponse) => { this.dialog.closeAll(); - return of(ErrorActions.snackBarError({ error: error.error })); + return of( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); }) ) ) @@ -220,7 +222,9 @@ export class ParameterProvidersEffects { } }) ), - catchError((error) => of(ErrorActions.snackBarError({ error: error.error }))) + catchError((errorResponse: HttpErrorResponse) => + of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })) + ) ) ) ) @@ -396,16 +400,16 @@ export class ParameterProvidersEffects { } }) ), - catchError((error: HttpErrorResponse) => { - if (this.errorHelper.showErrorInContext(error.status)) { + catchError((errorResponse: HttpErrorResponse) => { + if (this.errorHelper.showErrorInContext(errorResponse.status)) { return of( ParameterProviderActions.parameterProvidersBannerApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ); } else { this.dialog.getDialogById(request.id)?.close('ROUTED'); - return of(this.errorHelper.fullScreenError(error)); + return of(this.errorHelper.fullScreenError(errorResponse.error)); } }) ) @@ -441,8 +445,8 @@ export class ParameterProvidersEffects { response: { parameterProvider: response } }) ), - catchError((error) => { - if (this.errorHelper.showErrorInContext(error.status)) { + catchError((errorResponse: HttpErrorResponse) => { + if (this.errorHelper.showErrorInContext(errorResponse.status)) { this.store.dispatch( ParameterProviderActions.selectParameterProvider({ request: { @@ -450,9 +454,11 @@ export class ParameterProvidersEffects { } }) ); - return of(ErrorActions.snackBarError({ error: error.error })); + return of( + ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); } else { - return of(ErrorActions.fullScreenError(error)); + return of(ErrorActions.fullScreenError(errorResponse.error)); } }) ) @@ -565,10 +571,10 @@ export class ParameterProvidersEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( ParameterProviderActions.parameterProvidersBannerApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -625,10 +631,10 @@ export class ParameterProvidersEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( ParameterProviderActions.parameterProvidersBannerApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts index 1e60d7cc190b..b5228490fe44 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/registry-clients/registry-clients.effects.ts @@ -268,10 +268,10 @@ export class RegistryClientsEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( RegistryClientsActions.registryClientsBannerApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) @@ -336,10 +336,10 @@ export class RegistryClientsEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( RegistryClientsActions.registryClientsSnackbarApiError({ - error: error.error + error: this.errorHelper.getErrorString(errorResponse) }) ) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts index 2893b0b9be8f..8f2c78456379 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts @@ -81,10 +81,12 @@ export class ErrorHelper { getErrorString(errorResponse: HttpErrorResponse, prefix?: string): string { let errorMessage = 'An unspecified error occurred.'; - if (errorResponse.error && errorResponse.status !== 0) { - errorMessage = errorResponse.error; - } else if (!errorResponse.error && errorResponse.status !== 0) { - errorMessage = errorResponse.message || `${errorResponse.status}`; + if (errorResponse.status !== 0) { + if (errorResponse.error) { + errorMessage = errorResponse.error; + } else { + errorMessage = errorResponse.message || `${errorResponse.status}`; + } } if (prefix) { return `${prefix} - [${errorMessage}]`; diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts index 9947ad983afa..906d8296a83a 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/property-table-helper.service.ts @@ -145,7 +145,9 @@ export class PropertyTableHelperService { take(1), tap({ error: (errorResponse: HttpErrorResponse) => { - this.store.dispatch(snackBarError({ error: errorResponse.error })); + this.store.dispatch( + snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) + ); } }), switchMap((implementingTypesResponse) => { diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/contoller-service-state/controller-service-state.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/contoller-service-state/controller-service-state.effects.ts index 4b57331c0b6c..cc82c108bed8 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/contoller-service-state/controller-service-state.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/contoller-service-state/controller-service-state.effects.ts @@ -29,6 +29,8 @@ import { ControllerServiceStateService } from '../../service/controller-service- import { ControllerServiceEntity, ControllerServiceReferencingComponentEntity, isDefinedAndNotNull } from '../shared'; import { SetEnableRequest, SetEnableStep } from './index'; import { MEDIUM_DIALOG } from '../../index'; +import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../../service/error-helper.service'; @Injectable() export class ControllerServiceStateEffects { @@ -36,7 +38,8 @@ export class ControllerServiceStateEffects { private actions$: Actions, private store: Store, private dialog: MatDialog, - private controllerServiceStateService: ControllerServiceStateService + private controllerServiceStateService: ControllerServiceStateService, + private errorHelper: ErrorHelper ) {} submitEnableRequest$ = createEffect(() => @@ -102,12 +105,12 @@ export class ControllerServiceStateEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( ControllerServiceActions.setEnableStepFailure({ response: { step: setEnableRequest.currentStep, - error: error.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -157,12 +160,12 @@ export class ControllerServiceStateEffects { previousStep: setEnableRequest.currentStep }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( ControllerServiceActions.setEnableStepFailure({ response: { step: setEnableRequest.currentStep, - error: error.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -228,12 +231,12 @@ export class ControllerServiceStateEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( ControllerServiceActions.setEnableStepFailure({ response: { step: setEnableRequest.currentStep, - error: error.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) @@ -274,12 +277,12 @@ export class ControllerServiceStateEffects { } }) ), - catchError((error) => + catchError((errorResponse: HttpErrorResponse) => of( ControllerServiceActions.setEnableStepFailure({ response: { step: setEnableRequest.currentStep, - error: error.error + error: this.errorHelper.getErrorString(errorResponse) } }) ) From 8072df4e248e88de9d31f0aaa0fab4adcbd0e385 Mon Sep 17 00:00:00 2001 From: Rob Fellows Date: Thu, 2 May 2024 12:58:56 -0400 Subject: [PATCH 4/4] use errorHelper.fullScreenError in favor of directly calling the fullScreenError action --- .../src/app/pages/flow-designer/state/flow/flow.effects.ts | 4 ++-- .../parameter-providers/parameter-providers.effects.ts | 4 ++-- .../src/main/nifi/src/app/service/error-helper.service.ts | 6 +++--- .../src/app/state/status-history/status-history.effects.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts index e546e60e0d10..44224036bbe1 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts @@ -3175,7 +3175,7 @@ export class FlowEffects { error: this.errorHelper.getErrorString(errorResponse) }); } else { - return ErrorActions.fullScreenError(errorResponse.error); + return this.errorHelper.fullScreenError(errorResponse); } } @@ -3183,7 +3183,7 @@ export class FlowEffects { if (this.errorHelper.showErrorInContext(errorResponse.status)) { return FlowActions.flowSnackbarError({ error: this.errorHelper.getErrorString(errorResponse) }); } else { - return ErrorActions.fullScreenError(errorResponse.error); + return this.errorHelper.fullScreenError(errorResponse); } } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts index 1340fb66bd93..54dea01f10b7 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/settings/state/parameter-providers/parameter-providers.effects.ts @@ -409,7 +409,7 @@ export class ParameterProvidersEffects { ); } else { this.dialog.getDialogById(request.id)?.close('ROUTED'); - return of(this.errorHelper.fullScreenError(errorResponse.error)); + return of(this.errorHelper.fullScreenError(errorResponse)); } }) ) @@ -458,7 +458,7 @@ export class ParameterProvidersEffects { ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }) ); } else { - return of(ErrorActions.fullScreenError(errorResponse.error)); + return of(this.errorHelper.fullScreenError(errorResponse)); } }) ) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts index 8f2c78456379..1d6a9940ac77 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts @@ -48,11 +48,11 @@ export class ErrorHelper { break; } - if (this.nifiCommon.isBlank(errorResponse.error)) { + if (errorResponse.status === 0 || !errorResponse.error) { message = 'An error occurred communicating with NiFi. Please check the logs and fix any configuration issues before restarting.'; } else { - message = errorResponse.error; + message = this.getErrorString(errorResponse); } return ErrorActions.fullScreenError({ @@ -70,7 +70,7 @@ export class ErrorHelper { handleLoadingError(status: string, errorResponse: HttpErrorResponse): Action { if (status === 'success') { if (this.showErrorInContext(errorResponse.status)) { - return ErrorActions.snackBarError({ error: errorResponse.error }); + return ErrorActions.snackBarError({ error: this.getErrorString(errorResponse) }); } else { return this.fullScreenError(errorResponse); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts index 1599f868fe9b..83b0238489fe 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/status-history/status-history.effects.ts @@ -209,7 +209,7 @@ export class StatusHistoryEffects { return of(StatusHistoryActions.statusHistoryBannerError({ error })); } else { - return of(ErrorActions.fullScreenError(errorResponse.error)); + return of(this.errorHelper.fullScreenError(errorResponse)); } } @@ -218,7 +218,7 @@ export class StatusHistoryEffects { const error = this.errorHelper.getErrorString(errorResponse, 'Failed to load Status History.'); return of(ErrorActions.snackBarError({ error })); } else { - return of(ErrorActions.fullScreenError(errorResponse.error)); + return of(this.errorHelper.fullScreenError(errorResponse)); } } }