Skip to content

fix(#130): render text content if code parsing fails #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
};
Loading