Reputation: 6683
I am trying to debug my Module installation where a few times it will return false based on certain fields. Depending on which fails, I want to display an output. I have tried:
\Tools::displayError('This worked.');
array_push($this->context->controller->errors, $this->l('This worked.'));
My install looks like this:
public function install() {
\Tools::displayError('This worked.');
array_push($this->context->controller->errors, $this->l('This worked.'));
return (parent::install() && false); // Force a fail to test
}
However, all I seem to get is:
Unfortunately, the module did not return additional details.
I have looked on the internet for fixes but have only come across outdated ones. Any help would be appreciated.
Edit: my constructor has need_instance set to 1:
public function __construct() {
...
$this->need_instance = 1;
...
parent::__construct();
...
}
Update: To help future viewers, the insert
function of the Db
class automatically adds the prefix to the table name. Removing the self::DB_PREFIX
fixed this issue.
return \Db::getInstance()->insert('iezon_portfolio', array(
'img_link' => pSQL($img),
'title' => pSQL($title),
'description' => pSQL($description),
'company_name' => pSQL($company),
'company_url' => pSQL($company_url),
'testimonial' => pSQL($testimonial),
'is_favourite' => (int) $fav,
));
Upvotes: 1
Views: 834
Reputation: 1491
Try something like this:
public function install()
{
if ($this->checkForErrors()) {
$this->_errors[] = $this->l('Error message');
return false;
}
...rest of the code...
}
Upvotes: 2