Browse Source

fix: load table even if formula error is present (#9299)

Co-authored-by: mertmit <mertmit99@gmail.com>
pull/9373/head
Raju Udava 3 months ago committed by GitHub
parent
commit
c9f56650e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      packages/nc-gui/composables/useViewData.ts
  2. 7
      packages/nc-gui/store/tables.ts
  3. 5
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts
  4. 9
      packages/nocodb/src/helpers/catchError.ts

13
packages/nc-gui/composables/useViewData.ts

@ -16,7 +16,8 @@ export function useViewData(
viewMeta: Ref<ViewType | undefined> | ComputedRef<(ViewType & { id: string }) | undefined>,
where?: ComputedRef<string | undefined>,
) {
const { activeTableId, activeTable } = storeToRefs(useTablesStore())
const tablesStore = useTablesStore()
const { activeTableId, activeTable } = storeToRefs(tablesStore)
const meta = computed(() => _meta.value || activeTable.value)
const metaId = computed(() => _meta.value?.id || activeTableId.value)
@ -199,6 +200,16 @@ export function useViewData(
if (error.code === 'ERR_CANCELED') {
return
}
// retry the request if the error is FORMULA_ERROR
if (error?.response?.data?.error === 'FORMULA_ERROR') {
message.error(await extractSdkResponseErrorMsg(error))
await tablesStore.reloadTableMeta(metaId.value as string)
return loadData(params, shouldShowLoading)
}
console.error(error)
return message.error(await extractSdkResponseErrorMsg(error))
}

7
packages/nc-gui/store/tables.ts

@ -228,6 +228,12 @@ export const useTablesStore = defineStore('tablesStore', () => {
return url.href
}
const reloadTableMeta = async (tableId: string) => {
const { getMeta } = useMetas()
await getMeta(tableId, true)
}
return {
baseTables,
loadProjectTables,
@ -239,6 +245,7 @@ export const useTablesStore = defineStore('tablesStore', () => {
activeTableId,
navigateToTable,
tableUrl,
reloadTableMeta,
}
})

5
packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

@ -23,6 +23,7 @@ import { convertDateFormatForConcat } from '~/helpers/formulaFnHelper';
import FormulaColumn from '~/models/FormulaColumn';
import { BaseUser, ButtonColumn } from '~/models';
import { getRefColumnIfAlias } from '~/helpers';
import { ExternalTimeout, NcError } from '~/helpers/catchError';
const logger = new Logger('FormulaQueryBuilderv2');
@ -1373,7 +1374,7 @@ export default async function formulaQueryBuilderv2(
await NocoCache.update(`${CacheScope.COL_BUTTON}:${column.id}`, {
error: e.message,
});
} else {
} else if (!(e instanceof ExternalTimeout)) {
// add formula error to show in UI
await FormulaColumn.update(context, column.id, {
error: e.message,
@ -1385,7 +1386,7 @@ export default async function formulaQueryBuilderv2(
});
}
}
throw new Error(`Formula error: ${e.message}`);
NcError.formulaError(e.message);
}
return qb;
}

9
packages/nocodb/src/helpers/catchError.ts

@ -484,6 +484,8 @@ export class ExternalError extends NcBaseError {
}
}
export class ExternalTimeout extends ExternalError {}
export class UnprocessableEntity extends NcBaseError {}
export class AjvError extends NcBaseError {
@ -888,6 +890,13 @@ export class NcError {
});
}
static formulaError(message: string, args?: NcErrorArgs) {
throw new NcBaseErrorv2(NcErrorType.FORMULA_ERROR, {
params: message,
...args,
});
}
static notFound(message = 'Not found') {
throw new NotFound(message);
}

Loading…
Cancel
Save