推荐指数:10分
ceptionclassesfromwhichitisderived.Twoexceptionclassesthatarenotrelatedviasubclassingareneverequivalent,eveniftheyhavethesamename.
Thebuilt-inexceptionslistedbelowcanbegeneratedbytheinterpreterbuilt-infunctions.Exceptwherementioned,theyhavean“associatedvalue”indicatingthedetailedcauseoftheerror.Thismaybeastringatupleofseveralitemsofinformatione.g.,anerrorcodeastringexplainingthecode.Theassociatedvalueisusuallypassedasargumentstotheexceptionclass’sconstructor.
Usercodecanraisebuilt-inexceptions.Thiscanbeusedtotestanexceptionhandlertoreportanerrorcondition“justlike”thesituationinwhichtheinterpreterraisesthesameexception;butbewarethatthereisnothingtopreventusercodefromraisinganinappropriateerror.
Thebuilt-inexceptionclassescanbesubclassedtodefinenewexceptions;programmersareencouragedtoderi