From b433cf3d60e84f4446a4687942fb2278aaa45f38 Mon Sep 17 00:00:00 2001 From: weryques Date: Tue, 5 Dec 2017 10:28:38 -0200 Subject: [PATCH] Improvements on catch errors --- composer.json | 4 ++-- package.json | 2 +- tests/factories/class-tainacan-entity-factory.php | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index e1a34004c..524f7f3e8 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "medialabufg/tainacan-test-repo", - "description": "Protótipo", + "name": "medialabufg/tainacan", + "description": "Transforme seu site wordpress em um repositório digital.", "type": "wordpress-plugin", "require": { "respect/validation": "^1.1" diff --git a/package.json b/package.json index b03df3991..78622ff3b 100644 --- a/package.json +++ b/package.json @@ -23,4 +23,4 @@ "webpack": "2.1.0-beta.25", "webpack-dev-server": "2.1.0-beta.0" } -} \ No newline at end of file +} diff --git a/tests/factories/class-tainacan-entity-factory.php b/tests/factories/class-tainacan-entity-factory.php index 869d3de44..2a7491ee8 100644 --- a/tests/factories/class-tainacan-entity-factory.php +++ b/tests/factories/class-tainacan-entity-factory.php @@ -22,6 +22,8 @@ class Entity_Factory { * @throws \ErrorException */ public function create_entity($type, $args = [], $is_validated_and_in_db = false){ + ini_set('display_errors', 1); + try { if(empty($type)){ throw new \InvalidArgumentException(__('The type can\'t be empty')); @@ -79,7 +81,7 @@ class Entity_Factory { try { $this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_description( 'It is only for test' ); - } catch (\Exception $exception){ + } catch (\Error $exception){ $this->entity->set_title( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_description( 'It is only for test' ); } @@ -88,7 +90,7 @@ class Entity_Factory { try { $this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_description( 'It is only for test' ); - } catch (\Exception $exception){ + } catch (\Error $exception){ $this->entity->set_title( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_description( 'It is only for test' ); } @@ -103,9 +105,8 @@ class Entity_Factory { } else { throw new \InvalidArgumentException( __( 'One or more arguments are invalid.', 'tainacan' ) ); } - } catch (\Exception $exception){ - echo($exception->getMessage()); - echo($exception->getTraceAsString()); + } catch (\Error $exception){ + echo "\n" . $exception->getMessage() . "\n"; } return $this->entity;