0

I am trying to work out an effective way to catch and handle my errors. I am trying to build my own framework from scratch as an exercise.

I have many things to check and that throw errors if they don't exists or work as intended...

Here are some of the errors that exists around the framework...

For example, my Bootstrap.php file

enter image description here

and Container.php

enter image description here

So I am a bit confused about the overall architecture of 'gathering' these system errors together and displaying them... do I need to make a separate error class and error view and then just revert to the error view if an error is caught? Something like...

Error::handle('message here')

then in my Error.php file

class Error
{
    public function handle($message)
    {
        View::get('errors/error', $message);
    }
}
w3spi
  • 4,380
  • 9
  • 47
  • 80
Jethro Hazelhurst
  • 3,230
  • 7
  • 38
  • 80
  • 1
    maybe interesting? https://www.sitepoint.com/error-handling-in-php/ – Ryan Vincent Aug 01 '16 at 18:11
  • i think there are some points you need to reconsider your architecture. one obvious one is that your router should have a fallback route if no matches are found. there are other ones, but i think the code here illustrates a fundamental misunderstanding of mvc & more specifically, the model layer. see [here](http://stackoverflow.com/questions/5863870/how-should-a-model-be-structured-in-mvc/5864000#5864000) for initial reading – jeremy Aug 01 '16 at 21:21
  • @Jeremy thanks so much for the feedback, I wall be adding fall-backs, thanks for the tip. As for the misunderstanding, I have never understood this... I see that the model is not just a 'model' class but rather a network of behind the scenes classes and services. Sure, this is the case in most applications, but if the model is just a single class does that make it not a model? What if I just want to use one class to return results from a database and use that as a model? Is that breaking the MVC paradigm? – Jethro Hazelhurst Aug 04 '16 at 15:39
  • @JethroHazelhurst anything involved in the business logic/domain logic should be in the model layer. getting something from the database would be a part of this layer. if the class that does that is the only class in the model layer, it is not 'the model', it is still just a class contained *in* the model layer – jeremy Aug 05 '16 at 00:50

0 Answers0