Revert "Improve unhandled error handling in prod mode"
This reverts commit c2079276ebfa00cc03c738af4af99348deb5a287.
This commit is contained in:
		
							parent
							
								
									54ef08c039
								
							
						
					
					
						commit
						7196d6ede3
					
				
							
								
								
									
										22
									
								
								router.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								router.go
									
									
									
									
									
								
							| @ -368,8 +368,8 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ||||
| 			if _, ok := err.(middleware.HTTPException); ok { | ||||
| 				// catch intented errors, only for HTTP 4XX and 5XX | ||||
| 			} else { | ||||
| 				handler := p.getErrorHandler(fmt.Sprint(err)) | ||||
| 				if ErrorsShow { | ||||
| 				errstr := fmt.Sprint(err) | ||||
| 				if handler, ok := middleware.ErrorMaps[errstr]; ok && ErrorsShow { | ||||
| 					handler(rw, r) | ||||
| 				} else { | ||||
| 					if !RecoverPanic { | ||||
| @ -865,24 +865,6 @@ Admin: | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // there always should be error handler that sets error code accordingly for all unhandled errors | ||||
| // in order to have custom UI for error page it's necessary to override "500" error | ||||
| func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.ResponseWriter, r *http.Request) { | ||||
| 	handler := middleware.SimpleServerError | ||||
| 	ok := true | ||||
| 	if errorCode != "" { | ||||
| 		handler, ok = middleware.ErrorMaps[errorCode] | ||||
| 		if !ok { | ||||
| 			handler, ok = middleware.ErrorMaps["500"] | ||||
| 		} | ||||
| 		if !ok || handler == nil { | ||||
| 			handler = middleware.SimpleServerError | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	return handler | ||||
| } | ||||
| 
 | ||||
| //responseWriter is a wrapper for the http.ResponseWriter | ||||
| //started set to true if response was written to then don't execute other handler | ||||
| type responseWriter struct { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user