Log errors instead of giving exceptions

This commit is contained in:
James Cole 2019-08-12 18:19:06 +02:00
parent d96e77a3ec
commit 713a962005
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -25,6 +25,7 @@ namespace FireflyIII\Support;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use Log;
/** /**
* Class Navigation. * Class Navigation.
@ -37,8 +38,6 @@ class Navigation
* @param $skip * @param $skip
* *
* @return \Carbon\Carbon * @return \Carbon\Carbon
*
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip): Carbon public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip): Carbon
{ {
@ -73,7 +72,9 @@ class Navigation
]; ];
if (!isset($functionMap[$repeatFreq])) { if (!isset($functionMap[$repeatFreq])) {
throw new FireflyException(sprintf('Cannot do addPeriod for $repeat_freq "%s"', $repeatFreq)); Log::error(sprintf('Cannot do addPeriod for $repeat_freq "%s"', $repeatFreq));
return $theDate;
} }
if (isset($modifierMap[$repeatFreq])) { if (isset($modifierMap[$repeatFreq])) {
$add *= $modifierMap[$repeatFreq]; $add *= $modifierMap[$repeatFreq];
@ -169,8 +170,6 @@ class Navigation
* @param $repeatFreq * @param $repeatFreq
* *
* @return \Carbon\Carbon * @return \Carbon\Carbon
*
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function endOfPeriod(\Carbon\Carbon $end, string $repeatFreq): Carbon public function endOfPeriod(\Carbon\Carbon $end, string $repeatFreq): Carbon
{ {
@ -220,7 +219,9 @@ class Navigation
if (!isset($functionMap[$repeatFreq])) { if (!isset($functionMap[$repeatFreq])) {
throw new FireflyException(sprintf('Cannot do endOfPeriod for $repeat_freq "%s"', $repeatFreq)); Log::error(sprintf('Cannot do endOfPeriod for $repeat_freq "%s"', $repeatFreq));
return $end;
} }
$function = $functionMap[$repeatFreq]; $function = $functionMap[$repeatFreq];
@ -323,8 +324,6 @@ class Navigation
* @param string $repeatFrequency * @param string $repeatFrequency
* *
* @return string * @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function periodShow(\Carbon\Carbon $theDate, string $repeatFrequency): string public function periodShow(\Carbon\Carbon $theDate, string $repeatFrequency): string
{ {
@ -355,7 +354,10 @@ class Navigation
} }
// special formatter for quarter of year // special formatter for quarter of year
throw new FireflyException(sprintf('No date formats for frequency "%s"!', $repeatFrequency)); Log::error(sprintf('No date formats for frequency "%s"!', $repeatFrequency));
return $date->format('Y-m-d');
} }
/** /**
@ -478,8 +480,6 @@ class Navigation
* @param $repeatFreq * @param $repeatFreq
* *
* @return \Carbon\Carbon * @return \Carbon\Carbon
*
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon
{ {
@ -520,8 +520,10 @@ class Navigation
if ('custom' === $repeatFreq) { if ('custom' === $repeatFreq) {
return $date; // the date is already at the start. return $date; // the date is already at the start.
} }
Log::error(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $repeatFreq));
return $theDate;
throw new FireflyException(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $repeatFreq));
} }
/** /**