>Throw an error and handle it elsewhere.
>
>>Would it be better to save error codes and messages in the class properties instead and not pass them as parameters by reference? Do you think it will be a step in the right direction?
>>
>>I just proposed this to our internal team as another developer found limitations with our current approach.
We need to handle error somewhere. It's easier to handle the error exactly where it occurred because the ultimate goal is to pass error message (formatted special way) to the other application. So, immediately after the error occurred we want to format that return message and stop all other processing of that method. I don't want to write a special logic in each method to handle the error.
So, I think our idea of returning Boolean indicating success is OK. My only question is - do you think that using class properties for error codes and messages and may be some other stuff is better than passing the status code and message by reference? This is what I think we can change even though we already programmed a lot of methods using passed parameters by reference.
If it's not broken, fix it until it is.
My Blog