errors.js 793 B

12345678910111213141516171819202122232425262728293031323334
  1. const OError = require('@overleaf/o-error')
  2. class UnprocessableError extends OError {}
  3. class ApplyError extends UnprocessableError {
  4. constructor(message, operation, operand) {
  5. super(message)
  6. this.operation = operation
  7. this.operand = operand
  8. }
  9. }
  10. class InvalidInsertionError extends UnprocessableError {
  11. constructor(str, operation) {
  12. super('inserted text contains non BMP characters')
  13. this.str = str
  14. this.operation = operation
  15. }
  16. }
  17. class TooLongError extends UnprocessableError {
  18. constructor(operation, resultLength) {
  19. super('resulting string would be too long', { resultLength })
  20. this.operation = operation
  21. this.resultLength = resultLength
  22. }
  23. }
  24. module.exports = {
  25. UnprocessableError,
  26. ApplyError,
  27. InvalidInsertionError,
  28. TooLongError,
  29. }