import auth from '../auth/auth';

import bucketDelete from './bucketDelete';
import bucketGet from './bucketGet';
import bucketGetACL from './bucketGetACL';
import bucketHead from './bucketHead';
import bucketPut from './bucketPut';
import bucketPutACL from './bucketPutACL';
import completeMultipartUpload from './completeMultipartUpload';
import initiateMultipartUpload from './initiateMultipartUpload';
import listParts from './listParts';
import multipartDelete from './multipartDelete';
import objectDelete from './objectDelete';
import objectGet from './objectGet';
import objectGetACL from './objectGetACL';
import objectHead from './objectHead';
import objectPut from './objectPut';
import objectPutACL from './objectPutACL';
import objectPutPart from './objectPutPart';
import serviceGet from './serviceGet';

const api = {
    callApiMethod(apiMethod, request, log, callback) {
        auth(request, log, function authRes(err, accessKey) {
            if (err) {
                log.error('Authentication error:', { err });
                return callback(err);
            }
            try {
                this[apiMethod](accessKey, request, log, callback);
            } catch (e) {
                log.error(`Api method not found: ${apiMethod}`);
                log.error(e.message);
                return callback(new Error(e.message));
            }
        }.bind(this));
    },
    bucketDelete,
    bucketGet,
    bucketGetACL,
    bucketHead,
    bucketPut,
    bucketPutACL,
    completeMultipartUpload,
    initiateMultipartUpload,
    listParts,
    multipartDelete,
    objectDelete,
    objectGet,
    objectGetACL,
    objectHead,
    objectPut,
    objectPutACL,
    objectPutPart,
    serviceGet,
};

export default api;

@@ -1083,30 +1083,8 @@
   %7D%0A
-            try %7B%0A    
     
@@ -1147,206 +1147,8 @@
 k);%0A
-            %7D catch (e) %7B%0A                log.error(%60Api method not found: $%7BapiMethod%7D%60);%0A                log.error(e.message);%0A                return callback(new Error(e.message));%0A            %7D%0A
     

Remove try catch from api module calls