Request: Add util method to style object as error and use css class in output html

I have some scripts that's processing a large amount of files and from time to time, processing a file fails. Naturally if an exception is raised while I'm processing, I'd catch, log the exception (i.e., dump it) and continue. However this only dumps the exception styled as if it was any other normal object to be dumped. It seems the only way to get this red style is if there was a genuine uncaught exception.

There's no util method as far as I'm aware to style an object as if it as an error object so I was hoping I could add some custom styles to the dumped object to have it appear like an error and took a look at the output html. Not as trivial as I hoped since the styles are applied directly on the elements and not a simple css class I could apply.

So two requests:

  • Add a method to easily style an output as an error.
  • Error styles should be applied using css styles. Or perhaps in general, generate html that lends itself well to easily customize with css classes.


  • edited July 2022

    In the meantime, I've added these custom classes to my stylesheet. I think this matches how it is styled.

    .error > table[id]
        border-color: #B56172 !important;
        border-bottom: 2px solid;
    .error > table[id] > thead > tr > td.typeheader
        background: #B56172;
    .error > table[id] > thead > tr > td.summary
        background: #F4DEE3;
        color: black;

    And to use it:

    Util.WithCssClass(obj, "error").Dump();

    There's some additional work to have the same styling for expanded/collapsed objects (such as the bottom border color) but that's less of an issue for me. Ideally this would be easily customizable.

  • Thanks - I will refactor to use css selectors.

Sign In or Register to comment.