Welcome Guest, Not a member yet? Register   Sign In
Where in the file system do you save your Exception definitions?
#1

Where should one store one's custom Exception definitions? I looked at app/Config/Exceptions.php but that doesn't seem like the spot for them.

I did have some luck storing one in app/Models/Exception_DB.php:
PHP Code:
<?php
namespace App\Models;
/**
 * Defines Exception class for errors returned by my db wrapper when running queries.
 */
class Exception_DB extends \Exception {} 

You can throw this exception like so:
PHP Code:
throw new \App\Models\Exception_DB("wtf"); 

However, that seems like maybe a weird place to put it? I previously put these exceptions in application/core in my CI3 project.
Reply
#2

From what I read in the docs they should go into the folders that the exception is made for.

Model
Views
etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

You can create an `app/Exceptions/` folder and have all exception classes live there. Then just call your own exception like
PHP Code:
throw new \App\Exceptions\MyException(); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB