mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-15 16:41:44 +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 settings = require('settings-sharelatex')
|
||||||
const metrics = require('metrics-sharelatex')
|
const metrics = require('metrics-sharelatex')
|
||||||
const {
|
const {
|
||||||
|
ClientRequestedMissingOpsError,
|
||||||
DocumentUpdaterRequestFailedError,
|
DocumentUpdaterRequestFailedError,
|
||||||
NullBytesInOpError,
|
NullBytesInOpError,
|
||||||
UpdateTooLargeError
|
UpdateTooLargeError
|
||||||
|
@ -47,13 +48,7 @@ const DocumentUpdaterManager = {
|
||||||
body = body || {}
|
body = body || {}
|
||||||
callback(null, body.lines, body.version, body.ranges, body.ops)
|
callback(null, body.lines, body.version, body.ranges, body.ops)
|
||||||
} else if ([404, 422].includes(res.statusCode)) {
|
} else if ([404, 422].includes(res.statusCode)) {
|
||||||
err = new Error('doc updater could not load requested ops')
|
callback(new ClientRequestedMissingOpsError(res.statusCode))
|
||||||
err.statusCode = res.statusCode
|
|
||||||
logger.warn(
|
|
||||||
{ err, project_id, doc_id, url, fromVersion },
|
|
||||||
'doc updater could not load requested ops'
|
|
||||||
)
|
|
||||||
callback(err)
|
|
||||||
} else {
|
} else {
|
||||||
callback(
|
callback(
|
||||||
new DocumentUpdaterRequestFailedError('getDocument', res.statusCode)
|
new DocumentUpdaterRequestFailedError('getDocument', res.statusCode)
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
const OError = require('@overleaf/o-error')
|
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 {
|
class CodedError extends OError {
|
||||||
constructor(message, code) {
|
constructor(message, code) {
|
||||||
super(message, { code })
|
super(message, { code })
|
||||||
|
@ -63,6 +71,7 @@ class WebApiRequestFailedError extends OError {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
CodedError,
|
CodedError,
|
||||||
CorruptedJoinProjectResponseError,
|
CorruptedJoinProjectResponseError,
|
||||||
|
ClientRequestedMissingOpsError,
|
||||||
DataTooLargeToParseError,
|
DataTooLargeToParseError,
|
||||||
DocumentUpdaterRequestFailedError,
|
DocumentUpdaterRequestFailedError,
|
||||||
MissingSessionError,
|
MissingSessionError,
|
||||||
|
|
|
@ -136,14 +136,16 @@ describe('DocumentUpdaterManager', function () {
|
||||||
|
|
||||||
return it('should return the callback with an error', function () {
|
return it('should return the callback with an error', function () {
|
||||||
this.callback.called.should.equal(true)
|
this.callback.called.should.equal(true)
|
||||||
const err = this.callback.getCall(0).args[0]
|
this.callback
|
||||||
err.should.have.property('statusCode', statusCode)
|
.calledWith(
|
||||||
err.should.have.property(
|
sinon.match({
|
||||||
'message',
|
message: 'doc updater could not load requested ops',
|
||||||
'doc updater could not load requested ops'
|
info: { statusCode }
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
.should.equal(true)
|
||||||
this.logger.error.called.should.equal(false)
|
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