2019-12-18 05:01:59 -05:00
|
|
|
const OError = require('@overleaf/o-error')
|
|
|
|
|
|
|
|
// Error class for legacy errors so they inherit OError while staying
|
|
|
|
// backward-compatible (can be instantiated with string as argument instead
|
|
|
|
// of object)
|
|
|
|
class BackwardCompatibleError extends OError {
|
|
|
|
constructor(messageOrOptions) {
|
|
|
|
let options
|
|
|
|
if (typeof messageOrOptions === 'string') {
|
|
|
|
options = { message: messageOrOptions }
|
|
|
|
} else if (!messageOrOptions) {
|
|
|
|
options = {}
|
|
|
|
} else {
|
|
|
|
options = messageOrOptions
|
|
|
|
}
|
|
|
|
super(options)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class NotFoundError extends BackwardCompatibleError {}
|
2019-12-18 10:40:30 -05:00
|
|
|
class WriteError extends BackwardCompatibleError {}
|
|
|
|
class ReadError extends BackwardCompatibleError {}
|
2019-12-19 10:36:48 -05:00
|
|
|
class HealthCheckError extends BackwardCompatibleError {}
|
2019-12-18 05:01:59 -05:00
|
|
|
class ConversionsDisabledError extends BackwardCompatibleError {}
|
2019-12-18 10:40:30 -05:00
|
|
|
class ConversionError extends BackwardCompatibleError {}
|
2020-01-07 05:24:46 -05:00
|
|
|
class SettingsError extends BackwardCompatibleError {}
|
2020-01-07 16:19:26 -05:00
|
|
|
class TimeoutError extends BackwardCompatibleError {}
|
2019-12-18 05:01:59 -05:00
|
|
|
|
|
|
|
class FailedCommandError extends OError {
|
|
|
|
constructor(command, code, stdout, stderr) {
|
|
|
|
super({
|
|
|
|
message: 'command failed with error exit code',
|
|
|
|
info: {
|
|
|
|
command,
|
|
|
|
code
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.stdout = stdout
|
|
|
|
this.stderr = stderr
|
|
|
|
this.code = code
|
|
|
|
}
|
2019-12-16 05:42:31 -05:00
|
|
|
}
|
2015-08-31 11:47:16 -04:00
|
|
|
|
2019-12-18 10:40:30 -05:00
|
|
|
module.exports = {
|
|
|
|
NotFoundError,
|
|
|
|
FailedCommandError,
|
|
|
|
ConversionsDisabledError,
|
|
|
|
WriteError,
|
|
|
|
ReadError,
|
2019-12-19 10:36:48 -05:00
|
|
|
ConversionError,
|
2020-01-07 05:24:46 -05:00
|
|
|
HealthCheckError,
|
2020-01-07 16:19:26 -05:00
|
|
|
SettingsError,
|
|
|
|
TimeoutError
|
2019-12-18 10:40:30 -05:00
|
|
|
}
|