Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SimpleSAML\Error\Error extensible #1258

Open
jaimeperez opened this issue Dec 6, 2019 · 2 comments
Open

Make SimpleSAML\Error\Error extensible #1258

jaimeperez opened this issue Dec 6, 2019 · 2 comments
Labels
Milestone

Comments

@jaimeperez
Copy link
Member

@jaimeperez jaimeperez commented Dec 6, 2019

Currently, the SimpleSAML\Error\Error class doesn't support extending it easily. You would need to extend it in your own class, and reimplement large parts of it, in order to just get new errors in place. This is because the list of errors that it uses to initialize an error is hardcoded to those in SimpleSAML\Error\ErrorCodes.

Ideally, we should be able to extend (or substitute) the list in SimpleSAML\Error\ErrorCodes and make SimpleSAML\Error\Error use that list, so that whenever you need a custom error, you don't need to modify the code of SimpleSAMLphp or create your own exceptions, meaning you also need your own templates and everything.

We could actually use such a feature to extract some already existing errors to the modules where they belong, like CASERROR, LDAPERROR or MEMCACHEDOWN.

@jaimeperez jaimeperez added this to the 1.19 milestone Dec 6, 2019
@tvdijen

This comment has been minimized.

Copy link
Member

@tvdijen tvdijen commented Dec 6, 2019

I think this should be approached in a similar way as hooks.. The list of error-codes could be calculated & cached during installation, based on the modules that are enabled...

@jaimeperez

This comment has been minimized.

Copy link
Member Author

@jaimeperez jaimeperez commented Dec 12, 2019

Wouldn't that make it unnecessarily complicated? In the end, if you need custom codes, you are going to use them in your own code:

throw new SimpleSAML\Error\Error(MYCUSTOMERRORCODE);

Since you are already doing it in code, what prevents you from doing it also in code when you need it? E.g.:

throw new SimpleSAML\Module\mymod\MyError(MYCUSTOMERRORCODE);

In this case, MyError could be just extending \SimpleSAML\Error\Error, and injecting the error codes in the constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.