mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-15 05:11:57 +00:00
[DocumentUpdaterManager] use a new ClientRequestedMissingOpsError
This commit is contained in:
parent
8abfdb87ff
commit
4cb8cc4a85
3 changed files with 20 additions and 14 deletions
|
@ -7,6 +7,7 @@ const logger = require('logger-sharelatex')
|
|||
const settings = require('settings-sharelatex')
|
||||
const metrics = require('metrics-sharelatex')
|
||||
const {
|
||||
ClientRequestedMissingOpsError,
|
||||
DocumentUpdaterRequestFailedError,
|
||||
NullBytesInOpError,
|
||||
UpdateTooLargeError
|
||||
|
@ -47,13 +48,7 @@ const DocumentUpdaterManager = {
|
|||
body = body || {}
|
||||
callback(null, body.lines, body.version, body.ranges, body.ops)
|
||||
} else if ([404, 422].includes(res.statusCode)) {
|
||||
err = new Error('doc updater could not load requested ops')
|
||||
err.statusCode = res.statusCode
|
||||
logger.warn(
|
||||
{ err, project_id, doc_id, url, fromVersion },
|
||||
'doc updater could not load requested ops'
|
||||
)
|
||||
callback(err)
|
||||
callback(new ClientRequestedMissingOpsError(res.statusCode))
|
||||
} else {
|
||||
callback(
|
||||
new DocumentUpdaterRequestFailedError('getDocument', res.statusCode)
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
const OError = require('@overleaf/o-error')
|
||||
|
||||
class ClientRequestedMissingOpsError extends OError {
|
||||
constructor(statusCode) {
|
||||
super('doc updater could not load requested ops', {
|
||||
statusCode
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
class CodedError extends OError {
|
||||
constructor(message, code) {
|
||||
super(message, { code })
|
||||
|
@ -63,6 +71,7 @@ class WebApiRequestFailedError extends OError {
|
|||
module.exports = {
|
||||
CodedError,
|
||||
CorruptedJoinProjectResponseError,
|
||||
ClientRequestedMissingOpsError,
|
||||
DataTooLargeToParseError,
|
||||
DocumentUpdaterRequestFailedError,
|
||||
MissingSessionError,
|
||||
|
|
|
@ -136,14 +136,16 @@ describe('DocumentUpdaterManager', function () {
|
|||
|
||||
return it('should return the callback with an error', function () {
|
||||
this.callback.called.should.equal(true)
|
||||
const err = this.callback.getCall(0).args[0]
|
||||
err.should.have.property('statusCode', statusCode)
|
||||
err.should.have.property(
|
||||
'message',
|
||||
'doc updater could not load requested ops'
|
||||
)
|
||||
this.callback
|
||||
.calledWith(
|
||||
sinon.match({
|
||||
message: 'doc updater could not load requested ops',
|
||||
info: { statusCode }
|
||||
})
|
||||
)
|
||||
.should.equal(true)
|
||||
this.logger.error.called.should.equal(false)
|
||||
return this.logger.warn.called.should.equal(true)
|
||||
this.logger.warn.called.should.equal(false)
|
||||
})
|
||||
})
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue