How to use the @nakedobjects/restful-objects.ErrorRepresentation 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
private handleError(response: HttpErrorResponse, originalUrl: string) {
        let category: ErrorCategory;
        let error: Ro.ErrorRepresentation | Ro.ErrorMap | string;

        if (response.status === HttpStatusCode.InternalServerError) {
            // this error should contain an error representatation
            const errorRep = new Ro.ErrorRepresentation();
            if (Ro.isErrorRepresentation(response.error)) {
                errorRep.populate(response.error as Ro.IErrorRepresentation);
                category = ErrorCategory.HttpServerError;
                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 ||