Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/handlers/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function handler (req, res, next) {
if (err) {
debug('Error processing certificate: ' + err.message)
setEmptySession(req)
return next(error(403, err.message))
return next(error(403, 'Forbidden'))
}
req.session.userId = result
req.session.identified = true
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function handler (req, res, next) {
translate(stream, baseUri, contentType, possibleRDFType, function (err, data) {
if (err) {
debug('error translating: ' + req.originalUrl + ' ' + contentType + ' -> ' + possibleRDFType + ' -- ' + 500 + ' ' + err.message)
return next(error(500, err.message))
return next(error(500, 'Error translating between RDF formats'))
}
debug(req.originalUrl + ' translating ' + contentType + ' -> ' + possibleRDFType)
res.setHeader('Content-Type', possibleRDFType)
Expand Down
6 changes: 3 additions & 3 deletions lib/handlers/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function patchHandler (req, res, next) {
return next()
})
} else {
return next(error(400, 'Sorry unknown patch content type: ' + patchContentType))
return next(error(400, 'Unknown patch content type: ' + patchContentType))
}
} // postOrPatch

Expand Down Expand Up @@ -141,7 +141,7 @@ function sparqlUpdate (filename, targetURI, text, callback) {

fs.readFile(filename, {encoding: 'utf8'}, function (err, dataIn) {
if (err) {
return callback(error(404, 'Patch: Original file read error:' + err))
return callback(error(404, 'Error reading the patch target'))
}

debug('PATCH -- target read OK ' + dataIn.length + ' bytes. Parsing...')
Expand All @@ -160,7 +160,7 @@ function sparqlUpdate (filename, targetURI, text, callback) {
if (err) {
var message = err.message || err // returns string at the moment
debug('PATCH FAILED. Returning 409. Message: \'' + message + '\'')
return callback(error(409, message))
return callback(error(409, 'Error when applying the patch'))
}
debug('PATCH -- Patched. Writeback URI base ' + targetURI)
var data = $rdf.serialize(target, targetKB, targetURI, targetContentType)
Expand Down
18 changes: 9 additions & 9 deletions lib/ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function LDP (argv) {
LDP.prototype.stat = function (file, callback) {
fs.stat(file, function (err, stats) {
if (err) {
return callback(error(err))
return callback(error(err, 'Can\'t read metadata'))
}

return callback(null, stats)
Expand All @@ -87,7 +87,7 @@ LDP.prototype.readFile = function (filename, callback) {
{ 'encoding': 'utf8' },
function (err, data) {
if (err) {
return callback(error(err, 'Can\'t read file: ' + err.message))
return callback(error(err, 'Can\'t read file'))
}

return callback(null, data)
Expand Down Expand Up @@ -132,7 +132,7 @@ LDP.prototype.listContainer = function (filename, uri, containerData, contentTyp
fs.readdir(filename, function (err, files) {
if (err) {
debug.handlers('GET -- Error reading files: ' + err)
return callback(error(err))
return callback(error(err, 'Can\'t read container'))
}

debug.handlers('Files in directory: ' + files)
Expand Down Expand Up @@ -160,7 +160,7 @@ LDP.prototype.listContainer = function (filename, uri, containerData, contentTyp
fileBaseUri,
'text/turtle')
} catch (dirErr) {
return callback(error(err, dirErr.message))
return callback(error(err, 'Can\'t parse container metadata'))
}
return callback(null, metadataGraph)
})
Expand Down Expand Up @@ -258,7 +258,7 @@ LDP.prototype.listContainer = function (filename, uri, containerData, contentTyp
$rdf.parse(containerData, resourceGraph, baseUri, 'text/turtle')
} catch (err) {
debug.handlers('GET -- Error parsing data: ' + err)
return callback(error(500, err.message))
return callback(error(500, 'Can\'t parse container'))
}

async.waterfall([
Expand Down Expand Up @@ -296,14 +296,14 @@ LDP.prototype.listContainer = function (filename, uri, containerData, contentTyp
],
function (err, data) {
if (err) {
return callback(error(500, err.message))
return callback(error(500, 'Can\'t list container'))
}
// TODO 'text/turtle' is fixed, should be contentType instead
// This forces one more translation turtle -> desired
serialize(resourceGraph, null, 'text/turtle', function (err, result) {
if (err) {
debug.handlers('GET -- Error serializing container: ' + err)
return callback(error(500, err.message))
return callback(error(500, 'Can\'t serialize container'))
}
return callback(null, result)
})
Expand Down Expand Up @@ -351,11 +351,11 @@ LDP.prototype.put = function (host, resourcePath, stream, callback) {
mkdirp(path.dirname(filePath), function (err) {
if (err) {
debug.handlers('PUT -- Error creating directory: ' + err)
return callback(error(err))
return callback(error(err, 'Failed to create the path to the new resource'))
}
var file = stream.pipe(fs.createWriteStream(filePath))
file.on('error', function () {
callback(error(500))
callback(error(500, 'Error writing data'))
})
file.on('finish', function () {
debug.handlers('PUT -- Wrote data to: ' + filePath)
Expand Down