mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
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 {}
|
|
class WriteError extends BackwardCompatibleError {}
|
|
class ReadError extends BackwardCompatibleError {}
|
|
class HealthCheckError extends BackwardCompatibleError {}
|
|
class ConversionsDisabledError extends BackwardCompatibleError {}
|
|
class ConversionError extends BackwardCompatibleError {}
|
|
class SettingsError extends BackwardCompatibleError {}
|
|
class TimeoutError extends BackwardCompatibleError {}
|
|
class InvalidParametersError extends BackwardCompatibleError {}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
NotFoundError,
|
|
FailedCommandError,
|
|
ConversionsDisabledError,
|
|
WriteError,
|
|
ReadError,
|
|
ConversionError,
|
|
HealthCheckError,
|
|
SettingsError,
|
|
TimeoutError,
|
|
InvalidParametersError
|
|
}
|