difference between errors and unchecked exceptions in java?

后端 未结 7 1114
时光取名叫无心
时光取名叫无心 2020-12-16 18:22

As we know if any error or any unchecked exception occurs then our program will halt, then what are the differences between those?

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 18:46

    The term «reasonable» is relative. As it is, also, the term «application»

    As middleware developer, I'm used to deal with unchecked exceptions thrown, or simply ignored, by application developers

    What is reasonable to be catched by an application is is a subset of what is reasonable to be catched by its underlying infrastructure (that is, itself, a kind of application)

    That's where unchecked exceptions are different from errors. An unchecked can be catched by the infrastructure (i.e. to be registered in a.database) but ignored by an application

    Registering an error could be impossible because there could be no JVM to run the registering code (or even the catching code), that's why it's not reasonable to catch them

    As an aside, checked exceptions are IMHO overused. Catching them to promote to runtime exceptions is too much usual

提交回复
热议问题