diff --git a/packages/jaeger-ui/src/utils/readJsonFile.test.js b/packages/jaeger-ui/src/utils/readJsonFile.test.js index b2d5f457bf..8fba9ce4c2 100644 --- a/packages/jaeger-ui/src/utils/readJsonFile.test.js +++ b/packages/jaeger-ui/src/utils/readJsonFile.test.js @@ -67,20 +67,14 @@ describe('fileReader.readJsonFile', () => { return expect(p).rejects.toMatchObject(expect.any(Error)); }); - it('rejects on malform JSON', () => { + it('rejects malformed JSON', () => { const file = new File(['not-json'], 'foo.json'); const p = readJsonFile({ file }); return expect(p).rejects.toMatchObject(expect.any(Error)); }); - it('loads multiple JSON data', () => { - let fileContent; - try { - fileContent = fs.readFileSync('src/utils/fixtures/otlp2jaeger-multi-in.json.txt', 'utf-8'); - } catch (err) { - console.error('Error reading file:', err); - throw err; - } + it('loads JSON-per-line data', () => { + let fileContent = fs.readFileSync('src/utils/fixtures/otlp2jaeger-multi-in.json.txt', 'utf-8'); const file = new File([fileContent], 'multi.json', { type: 'application/json' }); const p = readJsonFile({ file }); expect(p).resolves.toBeDefined(); diff --git a/packages/jaeger-ui/src/utils/readJsonFile.tsx b/packages/jaeger-ui/src/utils/readJsonFile.tsx index 2eb599a58e..d680c0df33 100644 --- a/packages/jaeger-ui/src/utils/readJsonFile.tsx +++ b/packages/jaeger-ui/src/utils/readJsonFile.tsx @@ -23,7 +23,7 @@ function tryParseMultiLineInput(input: string): any[] { const traceObj = JSON.parse(jsonString.trim()); parsedObjects.push(traceObj); } catch (error) { - throw new Error(`Error parsing JSON at line ${index+1}: ${(error as Error).message}`); + throw new Error(`Error parsing JSON at line ${index + 1}: ${(error as Error).message}`); } }); @@ -45,7 +45,7 @@ export default function readJsonFile(fileList: { file: File }): Promise try { traceObj = tryParseMultiLineInput(reader.result); } catch (error) { - reject(new Error(`Error processing JSON: ${(error as Error).message}`)); + reject(error); return; } }