use JSON encoding in error message to make it more clear what the value actually is (as [] would be displayed as an empty string because of its .toString() method)