Jump to content

Exception suitable for "Read-Only"


phant0m

Recommended Posts

Hi

 

I am implementing a read-only access to some specific attributes of a class via the magic __get method. I intend to raise an exception when trying to write to it using __set, but I'm not sure which exception is suitable to use.

 

Is there any predefined exception to indicate such an error or should I just go ahead and define my own?

Link to comment
Share on other sites

I have been thinking about using "LogicError", because in a way, it is I think, since you are not supposed to assign to it.

 

The other I was thinking about was something along the lines of Myframework_Types_Property_ReadOnlyException but I don't like that level of verbosity too much, to be honest :)

Link to comment
Share on other sites

Any other thougts on this?

 

Not really besides, "don't think too much about it." :P  The LogicException is fine (and would be the one that I would choose), unless you have any particular need or convention to have one specific to your framework.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.