To create a user-defined error you need to prepare the XML that describes the error code and corresponding message that you want to use as a user-defined error.
To resolve the error <PROTECT>, remove the read-only attribute of the system-wide library database (IRISLIB for InterSystems IRIS, CACHELIB for Caché/Ensemble/HealthShare (Caché-based))
Once you have finished importing the routine, remember to change it back to read-only.
[Version 2013.1 and above] [Management Portal] > [System Administration] > [Configuration] > [System Configuration] > [Local Database] Uncheck "Mount read-only" from the database name link.