merge barnch 'master'
[arvados-workbench2.git] / src / services / common-service / common-resource-service.ts
index cfae106b2dd5ed38746ca5ea1f5078990d77992f..0c99e7d4be10ce56c4b453e01448ad56254069fe 100644 (file)
@@ -41,7 +41,7 @@ export enum CommonResourceServiceError {
 
 export class CommonResourceService<T extends Resource> {
 
-    static mapResponseKeys = (response: { data: any }): Promise<any> =>
+    static mapResponseKeys = (response: { data: any }) =>
         CommonResourceService.mapKeys(_.camelCase)(response.data)
 
     static mapKeys = (mapFn: (key: string) => string) =>
@@ -73,8 +73,9 @@ export class CommonResourceService<T extends Resource> {
             .then(CommonResourceService.mapResponseKeys)
             .catch(({ response }) => {
                 actions.progressFn(reqId, false);
-                actions.errorFn(reqId, response.message);
-                Promise.reject<Errors>(CommonResourceService.mapResponseKeys(response));
+                const errors = CommonResourceService.mapResponseKeys(response) as Errors;
+                actions.errorFn(reqId, errors);
+                throw errors;
             });
     }
 
@@ -88,7 +89,7 @@ export class CommonResourceService<T extends Resource> {
         this.actions = actions;
     }
 
-    create(data?: Partial<T> | any) {
+    create(data?: Partial<T>) {
         return CommonResourceService.defaultResponse(
             this.serverApi
                 .post<T>(this.resourceType, data && CommonResourceService.mapKeys(_.snakeCase)(data)),