Merge pull request #8789 from nextcloud/proper-exception-logging

Use proper method to log exceptions
This commit is contained in:
Roeland Jago Douma 2018-03-12 22:01:10 +01:00 committed by GitHub
commit 66173e9b52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 17 deletions

View File

@ -81,7 +81,7 @@ try {
OCP\JSON::success(array('data' => $data)); OCP\JSON::success(array('data' => $data));
} catch (\OCP\Files\StorageNotAvailableException $e) { } catch (\OCP\Files\StorageNotAvailableException $e) {
\OCP\Util::logException('files', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files']);
OCP\JSON::error([ OCP\JSON::error([
'data' => [ 'data' => [
'exception' => StorageNotAvailableException::class, 'exception' => StorageNotAvailableException::class,
@ -89,7 +89,7 @@ try {
] ]
]); ]);
} catch (\OCP\Files\StorageInvalidException $e) { } catch (\OCP\Files\StorageInvalidException $e) {
\OCP\Util::logException('files', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files']);
OCP\JSON::error(array( OCP\JSON::error(array(
'data' => array( 'data' => array(
'exception' => StorageInvalidException::class, 'exception' => StorageInvalidException::class,
@ -97,7 +97,7 @@ try {
) )
)); ));
} catch (\Exception $e) { } catch (\Exception $e) {
\OCP\Util::logException('files', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files']);
OCP\JSON::error(array( OCP\JSON::error(array(
'data' => array( 'data' => array(
'exception' => \Exception::class, 'exception' => \Exception::class,

View File

@ -194,7 +194,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
)); ));
$this->testTimeout(); $this->testTimeout();
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
@ -261,7 +261,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
// we reached the end when the list is no longer truncated // we reached the end when the list is no longer truncated
} while ($objects['IsTruncated']); } while ($objects['IsTruncated']);
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
return true; return true;
@ -305,7 +305,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return IteratorDirectory::wrap($files); return IteratorDirectory::wrap($files);
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
} }
@ -333,7 +333,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return $stat; return $stat;
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
} }
@ -343,7 +343,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
try { try {
return $this->isRoot($path) || $this->headObject($path . '/'); return $this->isRoot($path) || $this->headObject($path . '/');
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
} }
@ -363,7 +363,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return 'dir'; return 'dir';
} }
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
@ -389,7 +389,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$this->deleteObject($path); $this->deleteObject($path);
$this->invalidateCache($path); $this->invalidateCache($path);
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
@ -405,7 +405,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
try { try {
return $this->readObject($path); return $this->readObject($path);
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
case 'w': case 'w':
@ -483,7 +483,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$this->testTimeout(); $this->testTimeout();
} }
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
@ -504,7 +504,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
)); ));
$this->testTimeout(); $this->testTimeout();
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
} else { } else {
@ -518,7 +518,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
)); ));
$this->testTimeout(); $this->testTimeout();
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
@ -591,7 +591,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
unlink($tmpFile); unlink($tmpFile);
return true; return true;
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false; return false;
} }
} }

View File

@ -247,7 +247,7 @@ class OC_Mount_Config {
throw $e; throw $e;
} }
} catch (Exception $exception) { } catch (Exception $exception) {
\OCP\Util::logException('files_external', $exception); \OC::$server->getLogger()->logException($exception, ['app' => 'files_external']);
throw $exception; throw $exception;
} }
} }

View File

@ -426,7 +426,7 @@ class OC {
// if session can't be started break with http 500 error // if session can't be started break with http 500 error
} catch (Exception $e) { } catch (Exception $e) {
\OCP\Util::logException('base', $e); \OC::$server->getLogger()->logException($e, ['app' => 'base']);
//show the user a detailed error page //show the user a detailed error page
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
OC_Template::printExceptionErrorPage($e); OC_Template::printExceptionErrorPage($e);