开发者

If I get a complete and valid HttpWebResponse but the contents are invalid, what type of exception should be thrown?

What I'm doing is grabbing JSON off a website to deserialise it with a DataContract class. So what if the response I get doesn't match the class? I would be getting a SerializationException, but I'm thinking it would be better as an InnerException to a different exception, as the response is therefore incomplete or not JSON at all.

Right now I'm thinking WebException, but I have no ideas for开发者_如何学编程 a WebExceptionStatus that would be correct. Or perhaps it would be better to just create a completely new exception type?


I decided to create something inheriting off Exception and setting the InnerException to the SerializationException, since I can catch the specific class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜