Made the date thing throw a FF error.

This commit is contained in:
James Cole 2015-08-02 08:53:34 +02:00
parent 223ea80860
commit c0d62237fc

View File

@ -3,6 +3,9 @@
namespace FireflyIII\Helpers\Csv\Converter; namespace FireflyIII\Helpers\Csv\Converter;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use InvalidArgumentException;
use Log;
use Session; use Session;
/** /**
@ -19,8 +22,16 @@ class Date extends BasicConverter implements ConverterInterface
public function convert() public function convert()
{ {
$format = Session::get('csv-date-format'); $format = Session::get('csv-date-format');
try {
$date = Carbon::createFromFormat($format, $this->value);
} catch (InvalidArgumentException $e) {
Log::error('Date conversion error: ' . $e->getMessage() . '. Value was "' . $this->value . '", format was "' . $format . '".');
$message = trans('firefly.csv_date_parse_error', ['format' => $format, 'value' => $this->value]);
throw new FireflyException($message);
}
$date = Carbon::createFromFormat($format, $this->value);
return $date; return $date;
} }