First let's get a list of all the errors that can be thrown:
print [attr for attr in dir(psspy) if 'error' in attr.lower()]
that gives a huge list of errors.
Let's track that back to some common ancestors.
errors = [getattr(psspy, attr) for attr in dir(psspy) if 'error' in attr.lower()]
error_classes = set([cls.__mro__[1:] for cls in errors])
The __mro__
attribute is the method resolution order, you could think of it as the chain of inheritance for a class.
This shows two unique inheritance trees:
psspy.PsseException, exceptions.Exception, exceptions.BaseException, object
psspy.PsseAPIError, psspy.PsseException, exceptions.Exception, ...
Based on these two, (and some further digging around), I know that every single PSSE error inherits from psspy.PsseAPIError
. So if you want to catch PSSE errors, put psspy.PsseAPIError
in your except
clause.
import psspy
# next line is critical. PSSE won't throw exceptions unless you set it to True
psspy.throwPsseExceptions = True
try:
psspy.pssecase('non-existant-file')
except psspy.PsseAPIError, e:
print e.apiname, e.ierr
For completeness. Here is the entire list of exceptions. With the exception of PsseAPIError
They all inherit from PsseAPIError
:
A2TrmdccharError
A2TrmdcconvcharError
A2TrmdcconvcountError
A2TrmdcconvcplxError
A2TrmdcconvintError
A2TrmdcconvrealError
A2TrmdcconvtypesError
A2TrmdccountError
A2TrmdccplxError
A2TrmdcintError
A2TrmdcrealError
A2TrmdctypesError
AareacharError
AareacountError
AareacplxError
AareaintError
AarearealError
AareatypesError
AbrncharError
AbrncountError
AbrncplxError
AbrnintError
AbrnrealError
AbrntypesError
AbuscharError
AbuscountError
AbuscplxError
AbusintError
AbusrealError
AbustypesError
AcccError
Accc_Multiple_Run_ReportError
Accc_Single_Run_ReportError
Accc_Single_Run_Report_2Error
Accc_Trip_CorError
Accc_Trip_Cor_2Error
Accc_With_CorError
Accc_With_Cor_2Error
Accc_With_DspError
Accc_With_TripError
AccorError
Accor_2Error
Activate_LicenseError
Add_Details_To_Opf_LogError
Add_Facts_Device_ModelError
Add_Fctsauxsignal_ModelError
Add_Load_ModelError
Add_Mtdcauxsignal_ModelError
Add_Mtdcline_ModelError
Add_Plant_ModelError
Add_Relay_ModelError
Add_Swshunt_ModelError
Add_Ttdcauxsignal_ModelError
Add_Ttdcline_ModelError
Add_Vsdcauxsignal_ModelError
Add_Vsdcline_ModelError
Add_Wind_ModelError
AddmodelfolderError
AddmodellibraryError
AfactsbuscharError
AfactsbuscountError
AfactsbuscplxError
AfactsbusintError
AfactsbusrealError
AfactsbustypesError
AfactscharError
AfactscountError
AfactscplxError
AfactsintError
AfactsrealError
AfactstypesError
AflowcharError
AflowcountError
AflowcplxError
AflowintError
AflowrealError
AflowtypesError
AfxshntbuscharError
AfxshntbuscountError
AfxshntbuscplxError
AfxshntbusintError
AfxshntbusrealError
AfxshntbustypesError
AfxshuntcharError
AfxshuntcountError
AfxshuntcplxError
AfxshuntintError
AfxshuntrealError
AfxshunttypesError
AgenbuscharError
AgenbuscountError
AgenbuscplxError
AgenbusintError
AgenbusrealError
AgenbustypesError
AlertError
Alert_OutputError
AloadcharError
AloadcountError
AloadcplxError
AloadintError
AloadrealError
AloadtypesError
AlodbuscharError
AlodbuscountError
AlodbuscplxError
AlodbusintError
AlodbusrealError
AlodbustypesError
AlphError
AmachcharError
AmachcountError
AmachcplxError
AmachintError
AmachrealError
AmachtypesError
AmultitrmdccharError
AmultitrmdcconvcharError
AmultitrmdcconvcountError
AmultitrmdcconvcplxError
AmultitrmdcconvintError
AmultitrmdcconvrealError
AmultitrmdcconvtypesError
AmultitrmdccountError
AmultitrmdccplxError
AmultitrmdcintError
AmultitrmdcrealError
AmultitrmdctypesError
AnsiError
AownercharError
AownercountError
AownercplxError
AownerintError
AownerrealError
AownertypesError
Append_AcccError
Apply_Alternate_Step_SizeError
Apply_Automatic_ScalingError
ArdatError
AreaError
Area_2Error
Area_DataError
Area_ZoneError
AredatError
AreintError
ArenamError
ArenumError
AreuseError
AritojError
ArnmError
AsccError
Ascc_2Error
Ascc_scfileError
AstrError
AswshcharError
AswshcountError
AswshcplxError
AswshintError
AswshrealError
AswshtypesError
AsysError
AsysdefError
AsysinitError
Atr3CharError
Atr3CountError
Atr3CplxError
Atr3IntError
Atr3RealError
Atr3TypesError
AtrncharError
AtrncountError
AtrncplxError
AtrnintError
AtrnrealError
AtrntypesError
AulistError
Auxmod_PackError
Auxmod_UnconnectedError
Auxmod_UserError
AvscdccharError
AvscdcconvcharError
AvscdcconvcountError
AvscdcconvcplxError
AvscdcconvintError
AvscdcconvrealError
AvscdcconvtypesError
AvscdccountError
AvscdccplxError
AvscdcintError
AvscdcrealError
AvscdctypesError
AwndcharError
AwndcountError
AwndcplxError
AwndintError
AwndrealError
AwndtypesError
AzonecharError
AzonecountError
AzonecplxError
AzoneintError
AzonerealError
AzonetypesError
Bad_Iter_Coarse_LimitError
Bad_Iter_Fine_LimitError
Base_FrequencyError
BeginreportError
BgenError
BkdyError
Branch_App_R_X_ChannelError
Branch_DataError
Branch_Mva_ChannelError
Branch_P_And_Q_ChannelError
Branch_P_ChannelError
BrchError
BrncurError
BrndatError
Brndt2Error
BrnfloError
BrnintError
BrnmscError
BrnmvaError
BrnsttError
BsnmError
BsysError
BsysaddError
BsysdefError
BsysinitError
BsysisdefError
BsysmemError
BsysoError
BsysrclError
Bus_DataError
Bus_Data_2Error
Bus_Frequency_ChannelError
Bus_InputError
Bus_NumberError
Bus_OutputError
Bus_Size_LevelError
BusdatError
Busdt1Error
Busdt2Error
BusexsError
BusintError
BusmsmError
BusnError
CaseError
Case_Title_DataError
Change_ChannelError
Change_Channel_Out_FileError
Change_ChricnError
Change_ConError
Change_Fctmod_ChricnError
Change_Fctmod_ConError
Change_Fctmod_DataError
Change_Fctmod_IconError
Change_Fctmod_VarError
Change_Fctsauxmod_ChricnError
Change_Fctsauxmod_ConError
Change_Fctsauxmod_DataError
Change_Fctsauxmod_IconError
Change_Fctsauxmod_VarError
Change_GrefError
Change_IconError
Change_Ldmod_ChricnError
Change_Ldmod_ConError
Change_Ldmod_DataError
Change_Ldmod_IconError
Change_Ldmod_VarError
Change_Mtdcauxmod_ChricnError
Change_Mtdcauxmod_ConError
Change_Mtdcauxmod_DataError
Change_Mtdcauxmod_IconError
Change_Mtdcauxmod_VarError
Change_Mtdclmod_ChricnError
Change_Mtdclmod_ConError
Change_Mtdclmod_DataError
Change_Mtdclmod_IconError
Change_Mtdclmod_VarError
Change_Plmod_ChricnError
Change_Plmod_ConError
Change_Plmod_DataError
Change_Plmod_IconError
Change_Plmod_VarError
Change_Rlmod_ChricnError
Change_Rlmod_ConError
Change_Rlmod_DataError
Change_Rlmod_IconError
Change_Rlmod_VarError
Change_StateError
Change_Swsmod_ChricnError
Change_Swsmod_ConError
Change_Swsmod_IconError
Change_Swsmod_VarError
Change_Ttdcauxmod_ChricnError
Change_Ttdcauxmod_ConError
Change_Ttdcauxmod_DataError
Change_Ttdcauxmod_IconError
Change_Ttdcauxmod_VarError
Change_Ttdclmod_ChricnError
Change_Ttdclmod_ConError
Change_Ttdclmod_DataError
Change_Ttdclmod_IconError
Change_Ttdclmod_VarError
Change_VarError
Change_VrefError
Change_Vsdcauxmod_ChricnError
Change_Vsdcauxmod_ConError ...
(more)
Hey great question. I don't know about official documentation. I haven't seen any. But I'll put something together here.
@JervisW: Great answer! This is actually more helpful than simple documentation because it shows me how to dig into the guts. Thanks!.