Improvements on catch errors

This commit is contained in:
weryques 2017-12-05 10:28:38 -02:00
parent a6d39f7666
commit b433cf3d60
3 changed files with 9 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "medialabufg/tainacan-test-repo", "name": "medialabufg/tainacan",
"description": "Protótipo", "description": "Transforme seu site wordpress em um repositório digital.",
"type": "wordpress-plugin", "type": "wordpress-plugin",
"require": { "require": {
"respect/validation": "^1.1" "respect/validation": "^1.1"

View File

@ -23,4 +23,4 @@
"webpack": "2.1.0-beta.25", "webpack": "2.1.0-beta.25",
"webpack-dev-server": "2.1.0-beta.0" "webpack-dev-server": "2.1.0-beta.0"
} }
} }

View File

@ -22,6 +22,8 @@ class Entity_Factory {
* @throws \ErrorException * @throws \ErrorException
*/ */
public function create_entity($type, $args = [], $is_validated_and_in_db = false){ public function create_entity($type, $args = [], $is_validated_and_in_db = false){
ini_set('display_errors', 1);
try { try {
if(empty($type)){ if(empty($type)){
throw new \InvalidArgumentException(__('The type can\'t be empty')); throw new \InvalidArgumentException(__('The type can\'t be empty'));
@ -79,7 +81,7 @@ class Entity_Factory {
try { try {
$this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only 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_title( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only for test' ); $this->entity->set_description( 'It is only for test' );
} }
@ -88,7 +90,7 @@ class Entity_Factory {
try { try {
$this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only 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_title( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only for test' ); $this->entity->set_description( 'It is only for test' );
} }
@ -103,9 +105,8 @@ class Entity_Factory {
} else { } else {
throw new \InvalidArgumentException( __( 'One or more arguments are invalid.', 'tainacan' ) ); throw new \InvalidArgumentException( __( 'One or more arguments are invalid.', 'tainacan' ) );
} }
} catch (\Exception $exception){ } catch (\Error $exception){
echo($exception->getMessage()); echo "\n" . $exception->getMessage() . "\n";
echo($exception->getTraceAsString());
} }
return $this->entity; return $this->entity;