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


Messages In This Thread
Where in the file system do you save your Exception definitions? - by sneakyimp - 12-18-2020, 05:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB