Skip to content

Commit b7409f0

Browse files
#RI-5856 - resolve comments
1 parent 6cf87e6 commit b7409f0

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

redisinsight/ui/src/utils/apiResponse.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {AxiosError, AxiosResponse} from 'axios'
2-
import {first, isArray, get, set} from 'lodash'
1+
import { AxiosError } from 'axios'
2+
import { first, isArray, get } from 'lodash'
33
import { AddRedisDatabaseStatus, EnhancedAxiosError, ErrorOptions, IBulkOperationResult } from 'uiSrc/slices/interfaces'
44
import { parseCustomError } from 'uiSrc/utils'
55

@@ -21,6 +21,7 @@ export const createAxiosError = (options: ErrorOptions): AxiosError => ({
2121
export const getApiErrorCode = (error: AxiosError) => error?.response?.status
2222

2323
export function getApiErrorMessage(error: AxiosError): string {
24+
// @ts-ignore
2425
const errorMessage = error?.response?.data?.message
2526
if (!error || !error.response) {
2627
return DEFAULT_ERROR_MESSAGE

redisinsight/ui/src/utils/transformers/transformRdiPipeline.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,12 @@ export const pipelineToJson = ({ config, jobs }: IPipeline, onError: (errors: IY
3232
config: {},
3333
jobs: []
3434
}
35-
const errors = []
35+
const errors: IYamlFormatError[] = []
36+
37+
result.config = yamlToJson(config, (msg) => errors.push({ filename: 'config', msg })) || {}
3638

37-
try {
38-
result.config = yaml.load(config) || {}
39-
} catch (e) {
40-
if (e instanceof YAMLException) {
41-
errors.push({ filename: 'config', msg: e.reason })
42-
}
43-
}
4439
result.jobs = jobs.reduce<{ [key: string]: unknown }>((acc, job) => {
45-
try {
46-
acc[job.name] = yaml.load(job.value) || {}
47-
} catch (e) {
48-
if (e instanceof YAMLException) {
49-
errors.push({ filename: job.name, msg: e.reason })
50-
}
51-
}
40+
acc[job.name] = yamlToJson(job.value, (msg) => errors.push({ filename: job.name, msg })) || {}
5241
return acc
5342
}, {})
5443

0 commit comments

Comments
 (0)