Skip to content

Commit

Permalink
fix(semantic hub): fix review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw committed Jul 17, 2024
1 parent d27a6e0 commit 4358b0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/pages/SemanticHub/ModelTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const ModelTable = ({ onModelSelect }: ModelTableProps) => {
message: '',
}

if (error !== '') {
if (error) {
errorObj.status = Number(error)
errorObj.message =
error && Number(error) >= 400 && Number(error) < 500

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'error' always evaluates to true.
Expand Down
9 changes: 4 additions & 5 deletions src/features/semanticModels/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import { createAsyncThunk } from '@reduxjs/toolkit'
import { Api } from './api'
import type { FilterParams, NewSemanticModel } from './types'
import type { ErrorResponse, FilterParams, NewSemanticModel } from './types'

const message = 'The server responded with an error.'

Expand All @@ -29,14 +29,13 @@ const fetchSemanticModels = createAsyncThunk(
async ({ filter }: { filter: FilterParams }) => {
try {
return await Api.getInstance().getModels(filter)
// Add an ESLint exception until there is a solution
// eslint-disable-next-line
} catch (error: any) {
} catch (error: unknown) {
console.error('api call error:', error)
throw Error(JSON.stringify(error.response.status))
throw Error(JSON.stringify((error as ErrorResponse).response.status))
}
}
)

const fetchSemanticModelById = createAsyncThunk(
'semantic/model/fetchById',
async (id: string) => {
Expand Down
10 changes: 7 additions & 3 deletions src/features/semanticModels/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

import type { Nullable } from 'types/MainTypes'

export interface ErrorResponse {
response: {
status: number
}
}

export interface SemanticModelsInitialState {
modelList: ModelList
loadingModelList: boolean
Expand All @@ -30,9 +36,7 @@ export interface SemanticModelsInitialState {
uploadError: string
openApiLink: string
openApiError: string
// Add an ESLint exception until there is a solution
// eslint-disable-next-line
error: any
error: ErrorResponse
deleteModelId: string
deleteError: string
}
Expand Down

0 comments on commit 4358b0f

Please sign in to comment.