Java Style: Properly handling exceptions

后端 未结 5 1485
孤独总比滥情好
孤独总比滥情好 2020-12-13 08:09

I keep getting stuck conceptually on deciding an Exception-handling structure for my project.

Suppose you have, as an example:

public abstract class          


        
5条回答
  •  醉话见心
    2020-12-13 08:30

    If you're not explicitly stating that read() can throw an exception, then you'll surprise developers when it does.

    In your particular case I'd catch the underlying exceptions and rethrow them as a new exception class DataException or DataReadException.

提交回复
热议问题