mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Don't repeat error messages infinitely
This commit is contained in:
		
							parent
							
								
									a031900b3e
								
							
						
					
					
						commit
						12b87c69c8
					
				| @ -37,9 +37,11 @@ var FeatureTogglesComponent = React.createClass({ | ||||
|         if (this.isClientError(error)) { | ||||
|             // TODO: catch SyntaxError | ||||
|             var errors = JSON.parse(error.responseText) | ||||
|             errors.forEach(function(e) {  this.state.errors.push(e.msg); }.bind(this)) | ||||
|             errors.forEach(function(e) { this.addError(e.msg); }.bind(this)) | ||||
|         } else if (error.status === 0) { | ||||
|             this.addError("server unreachable"); | ||||
|         } else { | ||||
|             this.state.errors.push(error); | ||||
|             this.addError(error); | ||||
|         } | ||||
| 
 | ||||
|         this.forceUpdate(); | ||||
| @ -88,6 +90,12 @@ var FeatureTogglesComponent = React.createClass({ | ||||
|         this.setState({errors: []}); | ||||
|     }, | ||||
| 
 | ||||
|     addError: function(msg) { | ||||
|         if (this.state.errors[this.state.errors.length - 1] !== msg) { | ||||
|             this.state.errors.push(msg); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     isClientError: function(error) { | ||||
|         try { | ||||
|             return error.status >= 400 && | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user