Transforms: Catch errors while running transforms (#73451)

This commit is contained in:
Ryan McKinley 2023-08-18 13:55:42 -07:00 committed by GitHub
parent ca64d919ad
commit e605c686f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import { cloneDeep } from 'lodash';
import { Observable, of, ReplaySubject, Unsubscribable } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { map, mergeMap, catchError } from 'rxjs/operators';
import {
ApplyFieldOverrideOptions,
@ -221,7 +221,17 @@ export class PanelQueryRunner {
interpolate: (v: string) => getTemplateSrv().replace(v, data?.request?.scopedVars),
};
return transformDataFrame(transformations, data.series, ctx).pipe(map((series) => ({ ...data, series })));
return transformDataFrame(transformations, data.series, ctx).pipe(
map((series) => ({ ...data, series })),
catchError((err) => {
console.warn('Error running transformation:', err);
return of({
...data,
state: LoadingState.Error,
error: toDataQueryError(err),
});
})
);
}
async run(options: QueryRunnerOptions) {