forked from Gitlink/gitea-1156
add:fix CreateWiki
This commit is contained in:
parent
75627d0ceb
commit
44cfd79573
|
@ -105,6 +105,29 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *APIContext) FileNameError(objs ...interface{}) {
|
||||||
|
var message = "FileName too long"
|
||||||
|
var errors []string
|
||||||
|
|
||||||
|
for _, obj := range objs {
|
||||||
|
// Ignore nil
|
||||||
|
if obj == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err, ok := obj.(error); ok {
|
||||||
|
errors = append(errors, err.Error())
|
||||||
|
} else {
|
||||||
|
message = obj.(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.JSON(500, map[string]interface{}{
|
||||||
|
"message": message,
|
||||||
|
"documentation_url": setting.API.SwaggerURL,
|
||||||
|
"errors": errors,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// InternalServerError responds with an error message to the client with the error as a message
|
// InternalServerError responds with an error message to the client with the error as a message
|
||||||
// and the file and line of the caller.
|
// and the file and line of the caller.
|
||||||
func (ctx *APIContext) InternalServerError(err error) {
|
func (ctx *APIContext) InternalServerError(err error) {
|
||||||
|
|
|
@ -153,6 +153,7 @@ func CreateWiki(ctx *context.APIContext) {
|
||||||
|
|
||||||
err := wiki_service.CheckFile(form.Name)
|
err := wiki_service.CheckFile(form.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
ctx.FileNameError()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue