2015-12-30 22 views
0

Pic where i am not getting error爲什麼錯誤消息在本地計算機中正確顯示,但不在QA UAT和prod計算機中?可能的原因是什麼?

I have written code for file upload which will allow only some particular files. If user will upload any wrong extension type of file, it will through error from the backend. I am doing all the validaton from backend only. Error message is showing very nicely in my local machine. But when i deploy the code on QA UAT or prod error message is not showing. I am getting Typeerror: canot read property '0' of undefined

In local we are notminifying the code. But in all other env it is minified. 

下面是我爲前端編寫的代碼。

scope.uploadFile = function (fileModel) { 
 
      Upload.upload({ 
 
       url: scope.url, 
 
       method: 'POST', 
 
       fields: {'requestId': scope.requestId, 'type': scope.type, 'isFileExisted' : fileModel.isFileExisted}, 
 
       file: fileModel.file, 
 
       fileFormDataName: 'myFile', 
 
       sendFieldsAs: scope.form 
 
      }).progress(function (evt) { // Progress bar. 
 
       fileModel.completion = parseInt(100.0 * evt.loaded/evt.total); 
 
      }).success(function (data, status, headers, config) { 
 
       fileModel.serverMessage = 'File uploaded successfully'; 
 
       fileModel.status = '200'; 
 
       fileModel.id = data.id; 
 
       scope.onUpload({document: data}); 
 
      }).error(function (data, status, headers, config) { 
 
       fileModel.status = '500'; 
 
       fileModel.serverMessage = data.errors[0].message; 
 
       return false; 
 
      }); 
 
     };
下面是我寫在後臺代碼,從有我扔 錯誤信息

def validateDocument(String type, def file, def requestObj) { 
 
     String errMsg 
 

 
\t \t \t if(type == 'treasury') 
 
\t \t \t { 
 
\t \t \t \t if (documents.findAll({ it.documentType == DocumentType.My_DOCUMENTS }).size() >= 5) 
 
\t \t \t \t { 
 
\t \t \t \t \t errMsg = "Maximum 5 attachments are allowed." 
 
\t \t \t \t } 
 
\t \t \t \t else if (documents.findAll{ it.documentType == DocumentType.My_DOCUMENTS }.find { it.fileName == file.originalFilename }) 
 
\t \t \t \t { 
 
\t \t \t \t \t errMsg = "File with same name already exists." 
 
\t \t \t \t } 
 
\t \t \t } 
 
\t   if (file.getSize() >= (1024 * 1024 * 5)) 
 
\t \t \t { 
 
       errMsg = "File size cannot exceed 5 MB." 
 
      } 
 
\t \t \t else if (!(mediaType == 'application/x-tika-ooxml' || mediaType == 'application/pdf')) 
 
\t \t \t { 
 
       errMsg = "Invalid file format. Please add .doc .docx .xls .xlsx .pdf only" 
 
      } 
 
\t \t \t else if (file.empty) 
 
\t \t \t { 
 
       errMsg = "File cannot be empty." 
 
      } 
 
     } 
 
     errMsg 
 
    }

Please see the attached image in which i have marked an arrow, where 
i am not getting error message.  
+0

由於縮小而產生嗎? –

+0

@ [http://stackoverflow.com/users/949476/dfsq]你能幫助嗎? –

回答

0

嘿我很抱歉這個問題......代碼沒有問題而不是縮小代碼。實際上,當我們從狀態碼(500,400,403,404)等後端拋出異常或錯誤時。由於安全過濾,它將被其他團隊過濾。這與組織的安全級別有關。

相關問題