[Include] try-catch for not-implemented features

Started by SA:MP, May 10, 2023, 02:54 PM

Previous topic - Next topic

0 Members and 7 Guests are viewing this topic.

SA:MP

[Include] try-catch for not-implemented features

This brings a solution to a rather common problem we had for years.



A very common problem:


Code:

stock MyFunc() {
    ObviousFeatureThatDoesNotExist();
}

stock ObviousFeatureThatDoesNotExist() {
    throw new NotImplementedInSampException();
}

Result: uncaught exception




Code:

stock ΟpenМp() {
    try {
        MyFunc();
    } catch (ObviousFeatureThatDoesNotExist e) {
        ImplementFeature(e);
    }

Result: the feature becomes implemented

Source: [Include] try-catch for not-implemented features