mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 06:23:03 +00:00
Added status code to RemoteDataError
This commit is contained in:
@@ -100,7 +100,11 @@ export class RemoteDataBuildService {
|
|||||||
isSuccessful = resEntry.response.isSuccessful;
|
isSuccessful = resEntry.response.isSuccessful;
|
||||||
const errorMessage = isSuccessful === false ? (resEntry.response as ErrorResponse).errorMessage : undefined;
|
const errorMessage = isSuccessful === false ? (resEntry.response as ErrorResponse).errorMessage : undefined;
|
||||||
if (hasValue(errorMessage)) {
|
if (hasValue(errorMessage)) {
|
||||||
error = new RemoteDataError((resEntry.response as ErrorResponse).statusText, errorMessage);
|
error = new RemoteDataError(
|
||||||
|
(resEntry.response as ErrorResponse).statusCode,
|
||||||
|
(resEntry.response as ErrorResponse).statusText,
|
||||||
|
errorMessage
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new RemoteData(
|
return new RemoteData(
|
||||||
@@ -247,7 +251,16 @@ export class RemoteDataBuildService {
|
|||||||
}).filter((c: string) => hasValue(c))
|
}).filter((c: string) => hasValue(c))
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
const error = new RemoteDataError(statusText, errorMessage);
|
const statusCode: number = arr
|
||||||
|
.map((d: RemoteData<T>) => d.error)
|
||||||
|
.map((e: RemoteDataError, idx: number) => {
|
||||||
|
if (hasValue(e)) {
|
||||||
|
return e.statusCode;
|
||||||
|
}
|
||||||
|
}).filter((c: number) => hasValue(c))
|
||||||
|
.reduce((acc, status) => status, undefined);
|
||||||
|
|
||||||
|
const error = new RemoteDataError(statusCode, statusText, errorMessage);
|
||||||
|
|
||||||
const payload: T[] = arr.map((d: RemoteData<T>) => d.payload);
|
const payload: T[] = arr.map((d: RemoteData<T>) => d.payload);
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
export class RemoteDataError {
|
export class RemoteDataError {
|
||||||
constructor(
|
constructor(
|
||||||
|
public statusCode: number,
|
||||||
public statusText: string,
|
public statusText: string,
|
||||||
public message: string
|
public message: string
|
||||||
) {
|
) {
|
||||||
|
Reference in New Issue
Block a user