mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
This reverts commit ce907417b7.
This commit is contained in:
@@ -213,23 +213,6 @@ describe('AdfHttpClient', () => {
|
||||
req.flush(errorResponse, { status: 403, statusText: 'Forbidden' });
|
||||
});
|
||||
|
||||
it('should return a meaningful error message when response body is null', (done) => {
|
||||
const options: RequestOptions = {
|
||||
path: '',
|
||||
httpMethod: 'POST'
|
||||
};
|
||||
|
||||
angularHttpClient.request('http://example.com', options, securityOptions, emitters).catch((err: AlfrescoApiResponseError) => {
|
||||
expect(err instanceof Error).toBeTruthy();
|
||||
expect(err.message).toBe('401 Unauthorized');
|
||||
expect(err.status).toBe(401);
|
||||
done();
|
||||
});
|
||||
|
||||
const req = controller.expectOne('http://example.com');
|
||||
req.flush(null, { status: 401, statusText: 'Unauthorized' });
|
||||
});
|
||||
|
||||
it('should return a Error type on failed promise with response body', (done) => {
|
||||
const options: RequestOptions = {
|
||||
path: '',
|
||||
|
||||
@@ -223,14 +223,7 @@ export class AdfHttpClient implements JsApiHttpClient {
|
||||
// for backwards compatibility we need to convert it to error class as the HttpErrorResponse only implements Error interface, not extending it,
|
||||
// and we need to be able to correctly pass instanceof Error conditions used inside repository
|
||||
// we also need to pass error as Stringify string as we are detecting statusCodes using JSON.parse(error.message) in some places
|
||||
let msg: string;
|
||||
if (err.error == null) {
|
||||
msg = `${err.status} ${err.statusText ?? 'Unknown error'}`;
|
||||
} else if (typeof err.error === 'string') {
|
||||
msg = err.error;
|
||||
} else {
|
||||
msg = JSON.stringify(err.error);
|
||||
}
|
||||
const msg = typeof err.error === 'string' ? err.error : JSON.stringify(err.error);
|
||||
|
||||
// for backwards compatibility to handle cases in code where we try read response.error.response.body;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user