2024-02-01 06:32:18 -05:00
|
|
|
const OError = require('@overleaf/o-error')
|
|
|
|
|
|
|
|
class UnprocessableError extends OError {}
|
|
|
|
|
|
|
|
class ApplyError extends UnprocessableError {
|
|
|
|
constructor(message, operation, operand) {
|
2024-08-09 08:12:16 -04:00
|
|
|
super(message)
|
2024-02-01 06:32:18 -05:00
|
|
|
this.operation = operation
|
|
|
|
this.operand = operand
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class InvalidInsertionError extends UnprocessableError {
|
|
|
|
constructor(str, operation) {
|
2024-08-09 08:12:16 -04:00
|
|
|
super('inserted text contains non BMP characters')
|
2024-02-01 06:32:18 -05:00
|
|
|
this.str = str
|
|
|
|
this.operation = operation
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TooLongError extends UnprocessableError {
|
|
|
|
constructor(operation, resultLength) {
|
2024-08-09 08:12:16 -04:00
|
|
|
super('resulting string would be too long', { resultLength })
|
2024-02-01 06:32:18 -05:00
|
|
|
this.operation = operation
|
|
|
|
this.resultLength = resultLength
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
UnprocessableError,
|
|
|
|
ApplyError,
|
|
|
|
InvalidInsertionError,
|
|
|
|
TooLongError,
|
|
|
|
}
|