throw errors on null arguments

This commit is contained in:
Luke Pulverenti 2014-11-04 18:50:26 -05:00
parent a19bc334f3
commit de886863b5

View File

@ -226,6 +226,13 @@
function getConnectUser(userId, accessToken) {
if (!userId) {
throw new Error("null userId");
}
if (!accessToken) {
throw new Error("null accessToken");
}
var url = "https://connect.mediabrowser.tv/service/user?id=" + userId;
return $.ajax({
@ -445,6 +452,13 @@
function getConnectServers() {
if (!self.connectToken()) {
throw new Error("null connectToken");
}
if (!self.connectUserId()) {
throw new Error("null connectUserId");
}
var deferred = $.Deferred();
var url = "https://connect.mediabrowser.tv/service/servers?userId=" + self.connectUserId();
@ -725,6 +739,13 @@
self.loginToConnect = function (username, password) {
if (!username) {
throw new Error("null username");
}
if (!password) {
throw new Error("null password");
}
var md5 = self.getConnectPasswordHash(password);
return $.ajax({
@ -776,6 +797,13 @@
self.getUserInvitations = function () {
if (!self.connectToken()) {
throw new Error("null connectToken");
}
if (!self.connectUserId()) {
throw new Error("null connectUserId");
}
var url = "https://connect.mediabrowser.tv/service/servers?userId=" + self.connectUserId() + "&status=Waiting";
return $.ajax({
@ -791,6 +819,16 @@
self.deleteServer = function (serverId) {
if (!serverId) {
throw new Error("null serverId");
}
if (!self.connectToken()) {
throw new Error("null connectToken");
}
if (!self.connectUserId()) {
throw new Error("null connectUserId");
}
var url = "https://connect.mediabrowser.tv/service/serverAuthorizations?serverId=" + serverId + "&userId=" + self.connectUserId();
return $.ajax({
@ -805,6 +843,16 @@
self.acceptServer = function (serverId) {
if (!serverId) {
throw new Error("null serverId");
}
if (!self.connectToken()) {
throw new Error("null connectToken");
}
if (!self.connectUserId()) {
throw new Error("null connectUserId");
}
var url = "https://connect.mediabrowser.tv/service/ServerAuthorizations/accept?serverId=" + serverId + "&userId=" + self.connectUserId();
return $.ajax({