Skip to content

Commit

Permalink
fix(#130): render text content if code parsing fails (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
followynne authored Aug 15, 2024
1 parent a3aacb5 commit c065147
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Serilog.Ui.Web/src/__tests__/util/prettyPrints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ describe('util: pretty prints', () => {

const actXml = await renderCodeContent('not an XML!', LogType.Xml);

expect(actXml).toBe('Content could not be parsed, as per expected type: xml');
expect(actXml).toBe('not an XML!');

const actJson = await renderCodeContent('not a JSON!', LogType.Json);

expect(actJson).toBe('Content could not be parsed, as per expected type: json');
expect(actJson).toBe('not a JSON!');

expect(consoleMock).toHaveBeenCalledTimes(2);
});
Expand Down
4 changes: 2 additions & 2 deletions src/Serilog.Ui.Web/src/app/util/prettyPrints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const renderCodeContent = async (
});
}
} catch {
console.warn(`${modalContent} is not a valid json!`);
return `Content could not be parsed, as per expected type: ${contentType}`;
console.warn(`Content could not be parsed, as per expected type: ${contentType}`);
return modalContent;
}
};

0 comments on commit c065147

Please sign in to comment.