It may be viewed as a cognitive deficiency, which (if severe and untreated, or treated badly) may constitute a sort of defectus animi, as specified in Can. 984, no. 3, in the Pio-Benedictine Code of Canon Law. It is my understanding that those who suffer from chronic depression or schizophrenia, for example, would be barred from Sacred Orders by reason of this prescription.
As with most impediments either to the Priesthood or Religious life, the situations and factors thereof are as diverse and sundry as the individuals to whom the impediments are applicable. A Father Confessor and Spiritual Director should be consulted, and the counsel of the Rectors of the particular Seminary to which the individual wishes to apply must be sought. A physician or therapist should also be consulted, if it is applicable.
The Priest has to bear the burden of all his flock, and each soul thereof individually, as a Father in distributing the Sacraments, teaching the doctrines of Holy Church and giving spiritual counsel, and as a Judge in the tribunal of Penance and in practical application of moral principles in individual cases. This necessitates a health of mind and body that is superlative, that a Priest may withstand physically and mentally the exhaustion and crosses proper to his state, especially in these times.