本文整理汇总了Golang中github.com/cristian-sima/Wisply/models/adapter.WisplyError.Message方法的典型用法代码示例。如果您正苦于以下问题:Golang WisplyError.Message方法的具体用法?Golang WisplyError.Message怎么用?Golang WisplyError.Message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cristian-sima/Wisply/models/adapter.WisplyError
的用法示例。
在下文中一共展示了WisplyError.Message方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Try
// Try It tries to log in the username
func (login *Login) Try(loginDetails map[string]interface{}) (adapter.WisplyError, error) {
deleteOldTokens()
thinkMessage := "We think the email or the password were not valid."
genericMessage := "There was a problem while login. " + thinkMessage
problem := adapter.WisplyError{}
result := isValidLogin(loginDetails)
if !result.IsValid {
problem.Data = result
fmt.Println(result.Errors)
return problem, errors.New("Error")
}
email := loginDetails["email"].(string)
account, err := GetAccountByEmail(email)
if err != nil {
problem.Message = genericMessage
return problem, errors.New(genericMessage)
}
passwordString := loginDetails["password"].(string)
validPassword := checkPasswordIsCorrect(account.Password, passwordString)
if !validPassword {
problem.Message = genericMessage
return problem, errors.New(genericMessage)
}
return problem, nil
}
示例2: InsertNewRepository
// InsertNewRepository tries to create a new repository
func InsertNewRepository(repositoryDetails map[string]interface{}) (adapter.WisplyError, error) {
problem := adapter.WisplyError{}
// check Institution
_, errInst := NewInstitution(repositoryDetails["institution"].(string))
if errInst != nil {
problem.Message = "This institution does not exist"
return problem, errors.New("Error")
}
result := hasValidInsertDetails(repositoryDetails)
if !result.IsValid {
problem.Data = result
return problem, errors.New("Error")
}
name := repositoryDetails["name"].(string)
description := repositoryDetails["description"].(string)
url := repositoryDetails["url"].(string)
institutionID := repositoryDetails["institution"].(string)
category := repositoryDetails["category"].(string)
publicURL := repositoryDetails["public-url"].(string)
sql := "INSERT INTO `repository` (`name`, `description`, `url`, `institution`, `category`, `public_url`) VALUES (?, ?, ?, ?, ?, ?)"
query, err := database.Connection.Prepare(sql)
query.Exec(name, description, url, institutionID, category, publicURL)
if err != nil {
problem.Message = "No repository like that"
return problem, errors.New("Error")
}
return problem, nil
}
示例3: InsertNewInstitution
// InsertNewInstitution tries to create a new institution
func InsertNewInstitution(institutionDetails map[string]interface{}) (adapter.WisplyError, error) {
problem := adapter.WisplyError{}
result := hasValidInstitutionInsertDetails(institutionDetails)
if !result.IsValid {
problem.Data = result
return problem, errors.New("Error")
}
name := institutionDetails["name"].(string)
description := institutionDetails["description"].(string)
url := institutionDetails["url"].(string)
logoURL := institutionDetails["logoURL"].(string)
wikiURL := institutionDetails["wikiURL"].(string)
wikiID := institutionDetails["wikiID"].(string)
sql := "INSERT INTO `institution` (`name`, `description`, `url`, `logo_URL`, `wiki_URL`, `wiki_ID`) VALUES (?, ?, ?, ?, ?, ?)"
query, err := database.Connection.Prepare(sql)
query.Exec(name, description, url, logoURL, wikiURL, wikiID)
if err != nil {
problem.Message = "No institution like that"
return problem, errors.New("Error")
}
return problem, nil
}
示例4: Try
// Try It tries to create a new account
func (register *Register) Try(userDetails map[string]interface{}) (adapter.WisplyError, error) {
var problem = adapter.WisplyError{}
result := isValidRegister(userDetails)
if !result.IsValid {
problem.Data = result
return problem, errors.New("Error")
}
email := userDetails["email"].(string)
emailUsed := register.checkEmailExists(email)
if emailUsed {
problem.Message = "Hmmm, the email " + email + " is already used."
return problem, errors.New("Error")
}
register.createNewAccount(userDetails)
return problem, nil
}