How to use the odata.error function in odata

To help you get started, we’ve selected a few odata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github forCrowd / WealthFramework / AngularClient / src / main / core / app-http.service.ts View on Github external
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 =&gt; {

                            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"
                            || "";
github forCrowd / WealthFramework / AngularClient / src / main / core / app-http-client / error-interceptor.ts View on Github external
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 =&gt; {
                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 =&gt; {

            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"
            || "";
github Breeze / breeze.server.net / Old / AspNetCore / Nuget.builds / Breeze.Client / content / Scripts / adapters / breeze.dataService.odata.js View on Github external
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) {

      }
    }
github Breeze / breeze.js / build / adapters / breeze.dataService.odata.js View on Github external
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);
github forCrowd / WealthFramework / ngClient / _system / js / lib / breeze-client / breeze.dataService.odata.js View on Github external
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);
github OfficeDev / Office-365-People-Controls / src / Office.Controls.PeopleAadDataProvider.js View on Github external
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;
github OfficeDev / Office-365-People-Controls / example / control / Office.Controls.PeoplePicker.js View on Github external
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('');
github Azure / azure-sdk-for-node / lib / common / lib / services / serviceclient.js View on Github external
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];
          }
github TossShinHwa / CMS / src / YangKai.BlogEngine.Web.Mvc / Content / app-admin / main.controllers.js View on Github external
}, function(error) {
        $scope.error = error.data['odata.error'].innererror.message;
        $scope.user.Password = '';
        return $scope.submitting = false;
      });
    };
github pnp / office365-cli / src / o365 / spo / commands / web / web-add.ts View on Github external
}, (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);
        }
      });
  }

odata

o.js is a isomorphic Odata Javascript library to simplify the request of data. The main goal is to build a standalone, lightweight and easy to understand Odata lib.

MIT
Latest version published 3 months ago

Package Health Score

76 / 100
Full package analysis