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

refactor(di): subclasses of BaseException should be immutable #2606

Closed
jeffbcross opened this issue Jun 18, 2015 · 4 comments
Closed

refactor(di): subclasses of BaseException should be immutable #2606

jeffbcross opened this issue Jun 18, 2015 · 4 comments
Labels
effort1: hours help wanted An issue that is suitable for a community contributor (based on its complexity/scope). refactoring Issue that involves refactoring or code-cleanup

Comments

@jeffbcross
Copy link
Contributor

(Related to #2580 and #2570)

The AbstractBindingError class in di/exceptions extends BaseException from facade/lang, and provides an addKey method to append the error's message with more information. @yjbanov suggests (and I agree) that it would be better to implement the addKey method to return a new AbstractBindingError, merging the input with the existing instance's message, to encourage/enforce immutability.

(There may be other subclasses that need to change as well; I just wanted to get this issue open before I left the office).

@vsavkin, I'm happy to make this change if you're not opposed to this (since you're the one who's done the most work on di).

@mhevery mhevery added the help wanted An issue that is suitable for a community contributor (based on its complexity/scope). label Jun 19, 2015
@jeffbcross
Copy link
Contributor Author

(I spoke with @vsavkin in person and he affirmed this approach)

@jeffbcross jeffbcross added refactoring Issue that involves refactoring or code-cleanup and removed state: Blocked labels Jun 22, 2015
@jeffbcross jeffbcross changed the title Should subclasses of BaseException be immutable? refactor(di): subclasses of BaseException should be immutable Jun 22, 2015
clamoriniere added a commit to clamoriniere/angular that referenced this issue Jul 7, 2015
…#2606

Change AbstractBindingError constructor to take List<any> as keys
Implement the AbstractBindingError.addKey(key) method to return a new AbstractBindingError

Fix issue: refactor(di): subclasses of BaseException should be immutable angular#2606
BreakingChanges: AbstractBindingError constructor takes now List<any> as keys instead only one key.
clamoriniere added a commit to clamoriniere/angular that referenced this issue Jul 7, 2015
…#2606

Change AbstractBindingError constructor to take List<any> as keys
Implement the AbstractBindingError.addKey(key) method to return a new AbstractBindingError

Fix issue: refactor(di): subclasses of BaseException should be immutable angular#2606
BreakingChanges: AbstractBindingError constructor takes now List<any> as keys instead only one key.
clamoriniere added a commit to clamoriniere/angular that referenced this issue Jul 7, 2015
…#2606

Change AbstractBindingError constructor to take List<any> as keys
Implement the AbstractBindingError.addKey(key) method to return a new AbstractBindingError

Fix issue: refactor(di): subclasses of BaseException should be immutable angular#2606
BreakingChanges: AbstractBindingError constructor takes now List<any> as keys instead only one key.
@mhevery
Copy link
Contributor

mhevery commented Aug 6, 2015

I have tried to merge #2923 in. I have rebased on master, but realized that current implementation has an issue because it turns concrete exception (ie InstantiationError) into a (AbstractBaseError). To fix this every subclass of AbstractBindingError has to implement its own addKey method. The issue is that the concrete constructors take Key rather then List<Key>, so they have to have their signatures changed.

I have decided to abandon this since added code payload and constructor signature complexity does not justify the benefit of the immutability. Given that the exception are only mutated in DI, I see very little value in turning it into immutable code.

Closing.

mhevery pushed a commit to mhevery/angular that referenced this issue Aug 6, 2015
…#2606

Change AbstractBindingError constructor to take List<any> as keys
Implement the AbstractBindingError.addKey(key) method to return a new AbstractBindingError

Fix issue: refactor(di): subclasses of BaseException should be immutable angular#2606
BreakingChanges: AbstractBindingError constructor takes now List<any> as keys instead only one key.

Closes angular#2923
@mhevery
Copy link
Contributor

mhevery commented Aug 24, 2015

WONT_FIX

@mhevery mhevery closed this as completed Aug 24, 2015
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: hours help wanted An issue that is suitable for a community contributor (based on its complexity/scope). refactoring Issue that involves refactoring or code-cleanup
Projects
None yet
Development

No branches or pull requests

2 participants