BrainStormDevel / perseo

A simple modular CMS optimized for SEO based on Slim v4
31 stars 7 forks source link

There's no exception thrown on failure. #9

Closed damianopetrungaro closed 5 years ago

damianopetrungaro commented 5 years ago

Here is an example: Class DB.

Why are you using this approach?

damianopetrungaro commented 5 years ago

You may consider this usage.

class DB extends Medoo
{
    public function __construct(
        string $type,
        string $name,
        string $server,
        string $username,
        string $password,
        string $prefix,
        $charset = "utf8"
    ) {
        try {
            parent::__construct([
                'database_type' => $type,
                'database_name' => $name,
                'server' => $server,
                'username' => $username,
                'password' => $password,
                'prefix' => $prefix,
                'charset' => $charset,
            ]);
        } catch (\Exception $e) {
            throw \PerSeo\DB\Exception\InvalidArgumentException::fromPrevious($e);
        }
    }
}
BrainStormDevel commented 5 years ago

Class changed, using direct Medoo Exception.