Setting the message of a custom Exception without passing it to the base constructor

后端 未结 5 1361
悲&欢浪女
悲&欢浪女 2021-02-11 12:20

I want to make a custom Exception in C#, but in theory I do need to do a little parsing first before I can make a human readable ExceptionMessage.

The problem is that th

5条回答
  •  孤街浪徒
    2021-02-11 12:50

    Just put the formatting code into a static method?

    public CustomException(dynamic json) : base(HumanReadable(json)) {}
    private static string HumanReadable(dynamic json) {
        return whatever you need to;
    }
    

提交回复
热议问题