mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[WebApiManager] use a new CorruptedJoinProjectResponseError
This commit is contained in:
parent
68bc9d0d23
commit
02a2382264
2 changed files with 13 additions and 8 deletions
|
@ -6,6 +6,12 @@ class CodedError extends OError {
|
|||
}
|
||||
}
|
||||
|
||||
class CorruptedJoinProjectResponseError extends OError {
|
||||
constructor() {
|
||||
super('no data returned from joinProject request')
|
||||
}
|
||||
}
|
||||
|
||||
class DataTooLargeToParseError extends OError {
|
||||
constructor(data) {
|
||||
super('data too large to parse', {
|
||||
|
@ -47,6 +53,7 @@ class WebApiRequestFailedError extends OError {
|
|||
|
||||
module.exports = {
|
||||
CodedError,
|
||||
CorruptedJoinProjectResponseError,
|
||||
DataTooLargeToParseError,
|
||||
MissingSessionError,
|
||||
NotAuthorizedError,
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
const request = require('request')
|
||||
const settings = require('settings-sharelatex')
|
||||
const logger = require('logger-sharelatex')
|
||||
const { CodedError, WebApiRequestFailedError } = require('./Errors')
|
||||
const {
|
||||
CodedError,
|
||||
CorruptedJoinProjectResponseError,
|
||||
WebApiRequestFailedError
|
||||
} = require('./Errors')
|
||||
|
||||
module.exports = {
|
||||
joinProject(project_id, user, callback) {
|
||||
|
@ -32,15 +36,9 @@ module.exports = {
|
|||
if (error) {
|
||||
return callback(error)
|
||||
}
|
||||
let err
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
if (!(data && data.project)) {
|
||||
err = new Error('no data returned from joinProject request')
|
||||
logger.error(
|
||||
{ err, project_id, user_id },
|
||||
'error accessing web api'
|
||||
)
|
||||
return callback(err)
|
||||
return callback(new CorruptedJoinProjectResponseError())
|
||||
}
|
||||
callback(
|
||||
null,
|
||||
|
|
Loading…
Reference in a new issue