Handle invalid responses better
Depending on the response code, returning an HTTPError here will let us retry later, if appropriate. // FREEBIE
This commit is contained in:
		
					parent
					
						
							
								7bf94c33d5
							
						
					
				
			
			
				commit
				
					
						acae4afce3
					
				
			
		
					 2 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -51,7 +51,8 @@ var TextSecureServer = (function() {
 | 
			
		|||
                    try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
 | 
			
		||||
                    if (options.validateResponse) {
 | 
			
		||||
                        if (!validateResponse(result, options.validateResponse)) {
 | 
			
		||||
                            reject(new Error('Invalid response'));
 | 
			
		||||
                            console.log(options.type, url, xhr.status, 'Error');
 | 
			
		||||
                            reject(HTTPError(xhr.status, result, options.stack));
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue