mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-17 09:06:26 +00:00
Improve error message in sorted() method
This commit is contained in:
parent
05d84b23a2
commit
bd766297ef
@ -101,7 +101,7 @@ JSValueRef ResultsSorted(JSContextRef ctx, JSObjectRef function, JSObjectRef thi
|
|||||||
std::vector<bool> ascending;
|
std::vector<bool> ascending;
|
||||||
|
|
||||||
if (RJSIsValueArray(ctx, arguments[0])) {
|
if (RJSIsValueArray(ctx, arguments[0])) {
|
||||||
RJSValidateArgumentCount(argumentCount, 1);
|
RJSValidateArgumentCount(argumentCount, 1, "Second argument is not allowed if passed an array of sort descriptors");
|
||||||
|
|
||||||
JSObjectRef js_prop_names = RJSValidatedValueToObject(ctx, arguments[0]);
|
JSObjectRef js_prop_names = RJSValidatedValueToObject(ctx, arguments[0]);
|
||||||
prop_count = RJSValidatedListLength(ctx, js_prop_names);
|
prop_count = RJSValidatedListLength(ctx, js_prop_names);
|
||||||
|
@ -58,21 +58,21 @@ std::string RJSValidatedStringForValue(JSContextRef ctx, JSValueRef value, const
|
|||||||
JSStringRef RJSStringForString(const std::string &str);
|
JSStringRef RJSStringForString(const std::string &str);
|
||||||
JSValueRef RJSValueForString(JSContextRef ctx, const std::string &str);
|
JSValueRef RJSValueForString(JSContextRef ctx, const std::string &str);
|
||||||
|
|
||||||
inline void RJSValidateArgumentCount(size_t argumentCount, size_t expected) {
|
inline void RJSValidateArgumentCount(size_t argumentCount, size_t expected, const char *message = NULL) {
|
||||||
if (argumentCount != expected) {
|
if (argumentCount != expected) {
|
||||||
throw std::invalid_argument("Invalid arguments");
|
throw std::invalid_argument(message ?: "Invalid arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RJSValidateArgumentCountIsAtLeast(size_t argumentCount, size_t expected) {
|
inline void RJSValidateArgumentCountIsAtLeast(size_t argumentCount, size_t expected, const char *message = NULL) {
|
||||||
if (argumentCount < expected) {
|
if (argumentCount < expected) {
|
||||||
throw std::invalid_argument("Invalid arguments");
|
throw std::invalid_argument(message ?: "Invalid arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RJSValidateArgumentRange(size_t argumentCount, size_t min, size_t max) {
|
inline void RJSValidateArgumentRange(size_t argumentCount, size_t min, size_t max, const char *message = NULL) {
|
||||||
if (argumentCount < min || argumentCount > max) {
|
if (argumentCount < min || argumentCount > max) {
|
||||||
throw std::invalid_argument("Invalid arguments");
|
throw std::invalid_argument(message ?: "Invalid arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user