If somebody else needs this, here is how I managed to display the warning message:
public function getOrderShippingCost($params)
{
...
//error is defined as public variable
$this->carrierError = $ret['errormsg'];
if (no errors found)
return $ret['total'];
else
return false;
// when false is returned, carrier is not displayed, but warning message is displayed using hookDisplayHeader
}
public function hookDisplayHeader($params)
{
if (isset($this->carrierError) &&
Tools::getValue('controller') == 'order' &&
Tools::getValue('step') == '2')
{
//running JS do display a warning message that carrier may be available if you fix the wrong field
...
}
}