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 {
|
class DataTooLargeToParseError extends OError {
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
super('data too large to parse', {
|
super('data too large to parse', {
|
||||||
|
@ -47,6 +53,7 @@ class WebApiRequestFailedError extends OError {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
CodedError,
|
CodedError,
|
||||||
|
CorruptedJoinProjectResponseError,
|
||||||
DataTooLargeToParseError,
|
DataTooLargeToParseError,
|
||||||
MissingSessionError,
|
MissingSessionError,
|
||||||
NotAuthorizedError,
|
NotAuthorizedError,
|
||||||
|
|
|
@ -4,7 +4,11 @@
|
||||||
const request = require('request')
|
const request = require('request')
|
||||||
const settings = require('settings-sharelatex')
|
const settings = require('settings-sharelatex')
|
||||||
const logger = require('logger-sharelatex')
|
const logger = require('logger-sharelatex')
|
||||||
const { CodedError, WebApiRequestFailedError } = require('./Errors')
|
const {
|
||||||
|
CodedError,
|
||||||
|
CorruptedJoinProjectResponseError,
|
||||||
|
WebApiRequestFailedError
|
||||||
|
} = require('./Errors')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
joinProject(project_id, user, callback) {
|
joinProject(project_id, user, callback) {
|
||||||
|
@ -32,15 +36,9 @@ module.exports = {
|
||||||
if (error) {
|
if (error) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
let err
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
if (!(data && data.project)) {
|
if (!(data && data.project)) {
|
||||||
err = new Error('no data returned from joinProject request')
|
return callback(new CorruptedJoinProjectResponseError())
|
||||||
logger.error(
|
|
||||||
{ err, project_id, user_id },
|
|
||||||
'error accessing web api'
|
|
||||||
)
|
|
||||||
return callback(err)
|
|
||||||
}
|
}
|
||||||
callback(
|
callback(
|
||||||
null,
|
null,
|
||||||
|
|
Loading…
Reference in a new issue