mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Improve error handling in FileHandler
This commit is contained in:
parent
27aaff7843
commit
a216be5fd3
1 changed files with 11 additions and 5 deletions
|
@ -7,7 +7,12 @@ const FileConverter = require('./FileConverter')
|
||||||
const KeyBuilder = require('./KeyBuilder')
|
const KeyBuilder = require('./KeyBuilder')
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
const ImageOptimiser = require('./ImageOptimiser')
|
const ImageOptimiser = require('./ImageOptimiser')
|
||||||
const { WriteError, ReadError, ConversionError } = require('./Errors')
|
const {
|
||||||
|
WriteError,
|
||||||
|
ReadError,
|
||||||
|
ConversionError,
|
||||||
|
NotFoundError
|
||||||
|
} = require('./Errors')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
insertFile,
|
insertFile,
|
||||||
|
@ -66,16 +71,17 @@ function getDirectorySize(bucket, projectId, callback) {
|
||||||
logger.log({ bucket, project_id: projectId }, 'getting project size')
|
logger.log({ bucket, project_id: projectId }, 'getting project size')
|
||||||
PersistorManager.directorySize(bucket, projectId, function(err, size) {
|
PersistorManager.directorySize(bucket, projectId, function(err, size) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.err({ bucket, project_id: projectId }, 'error getting size')
|
return callback(
|
||||||
err = new ReadError('error getting project size').withCause(err)
|
new ReadError('error getting project size').withCause(err)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return callback(err, size)
|
callback(null, size)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getStandardFile(bucket, key, opts, callback) {
|
function _getStandardFile(bucket, key, opts, callback) {
|
||||||
PersistorManager.getFileStream(bucket, key, opts, function(err, fileStream) {
|
PersistorManager.getFileStream(bucket, key, opts, function(err, fileStream) {
|
||||||
if (err && err.name !== 'NotFoundError') {
|
if (err && !(err instanceof NotFoundError)) {
|
||||||
logger.err(
|
logger.err(
|
||||||
{ bucket, key, opts: _scrubSecrets(opts) },
|
{ bucket, key, opts: _scrubSecrets(opts) },
|
||||||
'error getting fileStream'
|
'error getting fileStream'
|
||||||
|
|
Loading…
Reference in a new issue