Skip to content

Commit

Permalink
[imp] Use translations and unique error codes for the file copy excep…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
olleharstedt committed May 14, 2019
1 parent a6f2e8e commit 21c0408
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libraries/src/Filesystem/File.php
Expand Up @@ -464,7 +464,7 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe =
if (!$isSafe)
{
Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR03', $dest), Log::WARNING, 'jerror');
throw new \RuntimeException(Text::sprintf('Warning: File %s not uploaded for security reasons!', $dest), -1);
throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR03', $dest), 1);
}
}

Expand All @@ -486,7 +486,7 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe =
if (!$stream->upload($src, $dest))
{
Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_UPLOAD', $stream->getError()), Log::WARNING, 'jerror');
throw new \RuntimeException('JFile::upload: ' . $stream->getError(), -1);
throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_UPLOAD', $stream->getError()), 2);
}

return true;
Expand All @@ -513,7 +513,7 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe =
else
{
Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), Log::WARNING, 'jerror');
throw new \RuntimeException(Text::sprintf('Warning: Failed to move file: %1$s to %2$s', $src, $dest), -1);
throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), 3);
}
}
else
Expand All @@ -528,13 +528,13 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe =
else
{
Log::add(Text::_('JLIB_FILESYSTEM_ERROR_WARNFS_ERR01'), Log::WARNING, 'jerror');
throw new \RuntimeException('Warning: Failed to change file permissions!', -1);
throw new \RuntimeException(Text::_('JLIB_FILESYSTEM_ERROR_WARNFS_ERR01'), 4);
}
}
else
{
Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), Log::WARNING, 'jerror');
throw new \RuntimeException(Text::sprintf('Warning: Failed to move file: %1$s to %2$s', $src, $dest), -1);
throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), 3);
}
}

Expand Down

0 comments on commit 21c0408

Please sign in to comment.