CodeIgniter Forums
error handling in model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: error handling in model (/showthread.php?tid=17286)



error handling in model - El Forum - 03-31-2009

[eluser]webscriptz.be[/eluser]
Because the model is basically the 'place to be' when it comes to process logic i should also be the please to be to alert for errors or is this for controllers ?

can i or can't i do show_error() in a model?


error handling in model - El Forum - 03-31-2009

[eluser]TheFuzzy0ne[/eluser]
I don't think there's anything stopping you, but I think that technically, your model shouldn't do anything other than return data.


error handling in model - El Forum - 03-31-2009

[eluser]Mackstar[/eluser]
I wouldn't agree that the model is only for returning data. It is for processing data, hence if you use the model to trigger your errors like in Java's try catch throw exception thinking then models are a good place for this, however php is a little more limited than Java in this regard unless you design it that way. If you have data related errors written to logs then the model is also good. But to be truly mvc the actual showing of your errror needs to be handled by controller/view.


error handling in model - El Forum - 04-03-2009

[eluser]webscriptz.be[/eluser]
[quote author="Mackstar" date="1238564220"]I wouldn't agree that the model is only for returning data. It is for processing data, hence if you use the model to trigger your errors like in Java's try catch throw exception thinking then models are a good place for this, however php is a little more limited than Java in this regard unless you design it that way. If you have data related errors written to logs then the model is also good. But to be truly mvc the actual showing of your errror needs to be handled by controller/view.[/quote]

I see reason in this answer Mackstar, models give data - get and proces data so the easiest would be returning false in case of errors.