Adds context.LastError()
This commit is contained in:
		
							
								
								
									
										10
									
								
								gin.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								gin.go
									
									
									
									
									
								
							@ -4,6 +4,7 @@ import (
 | 
				
			|||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"encoding/xml"
 | 
						"encoding/xml"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"github.com/julienschmidt/httprouter"
 | 
						"github.com/julienschmidt/httprouter"
 | 
				
			||||||
	"html/template"
 | 
						"html/template"
 | 
				
			||||||
@ -258,6 +259,15 @@ func (c *Context) Error(err error, meta interface{}) {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *Context) LastError() error {
 | 
				
			||||||
 | 
						s := len(c.Errors)
 | 
				
			||||||
 | 
						if s > 0 {
 | 
				
			||||||
 | 
							return errors.New(c.Errors[s-1].Err)
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/************************************/
 | 
					/************************************/
 | 
				
			||||||
/******** METADATA MANAGEMENT********/
 | 
					/******** METADATA MANAGEMENT********/
 | 
				
			||||||
/************************************/
 | 
					/************************************/
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user