JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

Go - check if an error contains a string

发布时间 2023-12-03 21:34:02作者: ZhangZhihuiAAA

 

    if err != nil {
        if strings.Contains(sql.ErrNoRows.Error(), err.Error()) {
            ctx.JSON(http.StatusNotFound, errorResponse(err))
            return
        }

        ctx.JSON(http.StatusInternalServerError, errorResponse(err))
        return
    }

 

    本栏目推荐文章
  • Go 语言为什么不支持并发读写 map?
  • Go标准库:Go template用法详解
  • A connection was successfully established with the server but then an error
  • 2024-01-13:用go语言,现在有一个打怪类型的游戏,这个游戏是这样的,你有n个技能, 每一个技能会有一个伤害, 同时若怪物小于等于一定的血量,则该技能可能造成双倍伤害, 每一个技能最多只能释放
  • vscode错误:Unable to connect to VS Code server: Error in request.
  • 【解决方案】Error running,Command line is too long
  • 我开源了一个 Go 学习仓库
  • js string转html节点
  • go的并发梳理
  • fish和pacman:“error: Unable to read input file: 是一个目录”报错的处理
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们