1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 15:57:07 +01:00

Improve behavior of PEEK command.

This commit is contained in:
hacksalot
2016-01-18 18:35:38 -05:00
parent e72564162b
commit d220cedfeb
5 changed files with 33 additions and 20 deletions

View File

@ -11,7 +11,6 @@ Definition of the SafeJsonLoader class.
var FS = require('fs')
, HMSTATUS = require('../core/status-codes')
, SyntaxErrorEx = require('./syntax-error-ex');
@ -29,15 +28,13 @@ Definition of the SafeJsonLoader class.
// If we get here, either FS.readFileSync or JSON.parse failed.
// We'll return HMSTATUS.readError or HMSTATUS.parseError.
ret.ex = ( ret.raw && ret.raw.trim() ) ?
{ // JSON.parse failed, likely because of a SyntaxError
fluenterror: HMSTATUS.parseError,
inner: SyntaxErrorEx.is( ex ) ? new SyntaxErrorEx( ex ) : ex
} :
{ // FS.readFileSync failed, likely because of ENOENT or EACCES
fluenterror: HMSTATUS.readError,
inner: ex
};
var retRaw = ret.raw && ret.raw.trim();
ret.ex = {
operation: retRaw ? 'parse' : 'read',
inner: SyntaxErrorEx.is( ex ) ? (new SyntaxErrorEx( ex, retRaw )) : ex,
file: file
};
}