0

Imagine ライブラリを使用して例外を正しく管理していないと思います。

私のコードは次のとおりです。

use ....
use Imagine\Exception;
....

try {

    $imagine = new Imagine();

    $image = $imagine->open($img_path . DS . "tmpfile." . $extension)
        ->resize(new Box($cwidth, $cheight))
        ->crop(new Point($offsetx, $offsety), new Box(500, 500));

    ...

} catch (Imagine\Exception\Exception $e) {

    die("catch Imagine\Exception\Exception");
    $file = new File($img_path . DS . "tmpfile." . $extension);
    if ($file->exists()) {
        $file->delete();
    }

}

しかし、Imagine Exception では、それをキャッチできず、スクリプトが停止します。

私の間違いはどこですか?

4

1 に答える 1

0

修飾名を使用しているため、現在の名前空間に関して解決されます。つまり、Imagine\Exception\Exceptionに解決され\CurrentNamespace\Imagine\Exception\Exceptionます。それが存在しないため、何もキャッチしていません。

インポートされた名前空間 (ExceptionつまりException\Exceptionに解決される) を使用するか、適切な完全修飾名 (つまり\Imagine\Exception\Exception、 で始まる名前) を使用します。\\Imagine\Exception\Exception

PHP Manual > Language Reference > Namespaces > Using namespaces: Basicsも参照してください。

于 2015-06-09T18:58:29.843 に答える