How to use the @nakedobjects/restful-objects.ErrorMap function in @nakedobjects/restful-objects

To help you get started, we’ve selected a few @nakedobjects/restful-objects 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 NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / services / src / rep-loader.service.ts View on Github external
error = errorRep;
            } else {
                return this.handleInvalidResponse(ErrorCategory.HttpServerError);
            }
        } else if (response.status <= 0) {
            // failed to connect
            category = ErrorCategory.ClientError;
            error = `Failed to connect to server: ${response.url || 'unknown'}`;
        } else {
            category = ErrorCategory.HttpClientError;
            const message = (response.headers && response.headers.get('warning')) || 'Unknown client HTTP error';

            if (response.status === HttpStatusCode.BadRequest ||
                response.status === HttpStatusCode.UnprocessableEntity) {
                // these errors should contain a map
                error = new Ro.ErrorMap(response.error as Ro.IValueMap | Ro.IObjectOfType,
                    response.status,
                    message);
            } else if (response.status === HttpStatusCode.NotFound && this.isObjectUrl(originalUrl)) {
                // were looking for an object an got not found - object may be deleted
                // treat as http problem.
                category = ErrorCategory.HttpClientError;
                error = `Failed to connect to server: ${response.url || 'unknown'}`;
            } else if (response.status === HttpStatusCode.NotFound) {
                // general not found other than object - assume client programming error
                category = ErrorCategory.ClientError;
                error = `Failed to connect to server: ${response.url || 'unknown'}`;
            } else {
                error = message;
            }
        }
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / domain-object-view-model.ts View on Github external
.then((reloadedObj: Ro.DomainObjectRepresentation) => {
                if (this.routeData.dialogId) {
                    this.urlManager.closeDialogReplaceHistory(this.routeData.dialogId, this.onPaneId);
                }
                this.reset(reloadedObj, this.routeData, true);
                const em = new Ro.ErrorMap({}, 0, Msg.concurrencyMessage);
                Helpers.handleErrorResponse(em, this, this.properties);
            })
            .catch((reject: ErrorWrapper) => this.error.handleError(reject));
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / contributed-action-parent-view-model.ts View on Github external
const rejectAsNeedSelection = (action: Ro.ActionRepresentation | Ro.InvokableActionMember): ErrorWrapper | null => {
                if (this.isLocallyContributed(action)) {
                    if (selected.length === 0) {
                        const em = new Ro.ErrorMap({}, 0, Msg.noItemsSelected);
                        const rp = new ErrorWrapper(ErrorCategory.HttpClientError, HttpStatusCode.UnprocessableEntity, em);
                        return rp;
                    }
                }
                return null;
            };