Results 1 to 6 of 6
Thread: ErrorHandling on MVC
- 01-10-2013, 08:39 PM #1
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
ErrorHandling on MVC
Hi,
I have a program in MVC.
The Model and the view send exception (FileNotFound, IO...) to the Controller, witch threads the errors.
But when i start the Model, he has to read from a config file.
Since the controller is not started yet, i cannot pass the exception in case of an error to the Controller.
Is this good practice :
What is the best way of threading exceptions from model and view in a MVC ?Java Code:public static void main(String[] args) { Model m = new Model(); View v = new View(); Controller c = new Controller(m, v); m.readConfig(); }
Kind regards
Dipke
- 01-11-2013, 12:00 AM #2
Member
- Join Date
- Dec 2012
- Posts
- 74
- Rep Power
- 0
Re: ErrorHandling on MVC
You could instantiate the Controller first and have it instantiate the Model and the View.
- 01-11-2013, 09:31 AM #3
AN21XX
- Join Date
- Mar 2012
- Location
- Munich
- Posts
- 297
- Rep Power
- 2
Re: ErrorHandling on MVC
I do not understand your problem at all... who prevents you from handling the exception on the level of your method? Or wait for the controller to be initialized before loading the configuration?
Last edited by Sierra; 01-11-2013 at 09:34 AM.
I like likes!.gif)
- 01-11-2013, 10:06 AM #4
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
Re: ErrorHandling on MVC
Hi,
The Exception is threated on the level of the method, but an errormessage is displayed on the screen using a view.
And that is initialized when the controller starts. So the controller must be started before the message can be displayed.
@kaydell2 : is this what you mean :
Kind regardsJava Code:Controller c = new Controller(); c.setModel = new Model(); c.setView = new View();
- 01-11-2013, 10:18 AM #5
Member
- Join Date
- Dec 2012
- Posts
- 74
- Rep Power
- 0
Re: ErrorHandling on MVC
I was thinking something more like this, but I'm only now learning MVC myself.
Java Code:class Model { } class View { } public class Controller { private Model model; private View view; public Controller() { this.model = new Model(); this.view = new View(); } }
- 01-15-2013, 10:01 AM #6
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
Similar Threads
-
ErrorHandling in Java
By SindhuPal in forum New To JavaReplies: 3Last Post: 10-16-2012, 02:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks