Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handled = true;
break;
}
case 400: { // Bad request
if (body.ModelState) { // WebApi ModelState errors
for (let key in body.ModelState) {
if (body.ModelState.hasOwnProperty(key)) {
body.ModelState[key].forEach(item => {
errorMessage += item + "<br>";
});
}
}
} else if (body["odata.error"]) { // OData ModelState errors
const errors = body["odata.error"].innererror.message.split("\r\n") as string[];
errors.forEach(error => {
error = error.trim();
if (error) {
errorMessage += error + "<br>";
}
});
} else {
errorMessage = body.Message
|| body.error_description // "Token" end point returns an error response with "error_description"
|| "";
handled = true;
break;
}
case 400: { // Bad request
if (error.ModelState) { // WebApi ModelState errors
for (let key in error.ModelState) {
if (error.ModelState.hasOwnProperty(key)) {
error.ModelState[key].forEach(item => {
errorMessage += item + "<br>";
});
}
}
} else if (error["odata.error"]) { // OData ModelState errors
const odataErrors = error["odata.error"].innererror.message.split("\r\n") as string[];
odataErrors.forEach(odataError => {
odataError = odataError.trim();
if (odataError) {
errorMessage += odataError + "<br>";
}
});
} else {
errorMessage = error.Message
|| error.error_description // "Token" end point returns an error response with "error_description"
|| "";
result.statusText = error;
return result;
}
result.message = response.statusText;
result.statusText = response.statusText;
result.status = response.statusCode;
// non std
if (url) result.url = url;
result.body = response.body;
if (response.body) {
var nextErr;
try {
var body = JSON.parse(response.body);
result.body = body;
// OData v3 logic
if (body['odata.error']) {
body = body['odata.error'];
}
var msg = "";
do {
nextErr = body.error || body.innererror;
if (!nextErr) msg = msg + getMessage(body);
nextErr = nextErr || body.internalexception;
body = nextErr || body;
} while (nextErr);
if (msg.length > 0) {
result.message = msg;
}
} catch (e) {
}
}
return result;
}
result.message = response.statusText;
result.statusText = response.statusText;
result.status = response.statusCode;
// non std
if (url) result.url = url;
result.body = response.body;
if (response.body) {
var nextErr;
try {
var body = JSON.parse(response.body);
result.body = body;
// OData v3 logic
if (body['odata.error']) {
body = body['odata.error'];
}
var msg = "";
do {
nextErr = body.error || body.innererror;
if (!nextErr) msg = msg + getMessage(body);
nextErr = nextErr || body.internalexception;
body = nextErr || body;
} while (nextErr);
if (msg.length > 0) {
result.message = msg;
}
} catch (e) {
}
}
proto._catchNoConnectionError(result);
return result;
}
result.message = response.statusText;
result.statusText = response.statusText;
result.status = response.statusCode;
// non std
if (url) result.url = url;
result.body = response.body;
if (response.body) {
var nextErr;
try {
var body = JSON.parse(response.body);
result.body = body;
// OData v3 logic
if (body['odata.error']) {
body = body['odata.error'];
}
var msg = "";
do {
nextErr = body.error || body.innererror;
if (!nextErr) msg = msg + getMessage(body);
nextErr = nextErr || body.internalexception;
body = nextErr || body;
} while (nextErr);
if (msg.length > 0) {
result.message = msg;
}
} catch (e) {
}
}
proto._catchNoConnectionError(result);
xhr.onload = function () {
if (xhr.status === 401) {
callback('Unauthorized', null);
return;
}
if (xhr.status !== 200) {
callback('Unknown error', null);
return;
}
var result = JSON.parse(xhr.responseText), people = [];
if (result["odata.error"] !== undefined) {
callback(result["odata.error"], null);
return;
}
result.value.forEach(
function (e) {
var person = {};
person.displayName = e.displayName;
person.description = person.department = e.department;
person.jobTitle = e.jobTitle;
person.mail = e.mail;
person.workPhone = e.telephoneNumber;
person.mobile = e.mobile;
person.office = e.physicalDeliveryOfficeName;
person.sipAddress = e.userPrincipalName;
person.alias = e.mailNickname;
person.id = e.objectId;
xhr.onload = function () {
if (xhr.status === 401) {
callback('Unauthorized', null);
return;
}
if (xhr.status !== 200) {
callback('Unknown error', null);
return;
}
var result = JSON.parse(xhr.responseText), people = [];
if (result["odata.error"] !== undefined) {
callback(result["odata.error"], null);
return;
}
result.value.forEach(
function (e) {
var person = {};
person.DisplayName = e.displayName;
person.Description = e.department;
person.PersonId = e.objectId;
people.push(person);
});
if (people.length > self.maxResult) {
people = people.slice(0, self.maxResult);
}
callback(null, people);
};
xhr.send('');
ServiceClient._normalizeError = function (error, response) {
if (azureutil.objectIsString(error)) {
return new Error(error);
} else if (error) {
var normalizedError = {};
var odataErrorFormat = !!error['odata.error'];
var errorProperties = error.Error || error.error || error['odata.error'] || error;
if (odataErrorFormat) {
for (var property in errorProperties) {
if (errorProperties.hasOwnProperty(property)) {
var value = null;
if (property === Constants.ODATA_ERROR_MESSAGE &&
!azureutil.objectIsString(errorProperties[Constants.ODATA_ERROR_MESSAGE])) {
if (errorProperties[Constants.ODATA_ERROR_MESSAGE][Constants.ODATA_ERROR_MESSAGE_VALUE]) {
value = errorProperties[Constants.ODATA_ERROR_MESSAGE][Constants.ODATA_ERROR_MESSAGE_VALUE];
}
else {
value = 'missing value in the message property of the odata error format';
}
}
else {
value = errorProperties[property];
}
}, function(error) {
$scope.error = error.data['odata.error'].innererror.message;
$scope.user.Password = '';
return $scope.submitting = false;
});
};
}, (err: any): void => {
if (err === SpoWebAddCommand.DONE) {
cmd.log(siteInfo);
if (this.verbose) {
cmd.log(vorpal.chalk.green('DONE'));
}
cb();
return;
}
if (err.error &&
err.error['odata.error'] &&
err.error['odata.error'].message) {
cb(new CommandError(err.error['odata.error'].message.value));
}
else {
this.handleRejectedPromise(err, cmd, cb);
}
});
}