futriix-json/tst/integration/error_handlers.py
Roshan Khatri 926b6fd6fe
Contributing valkeyJSON module (#1)
Initial contribution for ValkeyJSON based off of Amazon implementation.
2024-11-29 07:47:54 -08:00

32 lines
1.1 KiB
Python

import re
class ErrorStringTester:
def is_syntax_error(string):
return string.startswith("SYNTAXERR") or \
string.startswith("unknown subcommand")
def is_nonexistent_error(string):
return string.startswith("NONEXISTENT")
def is_wrongtype_error(string):
return string.startswith("WRONGTYPE")
def is_number_overflow_error(string):
return string.startswith("OVERFLOW")
def is_outofboundaries_error(string):
return string.startswith("OUTOFBOUNDARIES")
def is_limit_exceeded_error(string):
return string.startswith("LIMIT")
def is_write_error(string):
return string.startswith("ERROR") or string.startswith("OUTOFBOUNDARIES") or \
string.startswith("WRONGTYPE") or string.startswith("NONEXISTENT")
# NOTE: Uses .find instead of .startswith in case prefix added in the future
def is_wrong_number_of_arguments_error(string):
return string.find("wrong number of arguments") >= 0 or \
string.lower().find('invalid number of arguments') >= 0