ApplicationException or create custom exceptions?

前端 未结 4 1346
天涯浪人
天涯浪人 2021-01-18 02:12

In my file repository, I will throw the following exceptions when the InsertFile() method is called:

  • When the upload file size limit is exceeded
4条回答
  •  伪装坚强ぢ
    2021-01-18 02:47

    Suppose it depends on how you plan on handling exceptions. Throwing specific exceptions lets you respond to them, um, specifically. For instance:

    try
    {
    }
    catch(FileSizeExceededException ex)
    {
    }
    catch(StorageCapacityExceededException ex)
    {
    }
    

提交回复
热议问题