小编AZZ*_*Z_B的帖子

ruby on rails 5.0.0.2不兼容并与gem mongoid冲突


ruby版本2.3.0

rails版本5.0.0.beta2

**GEMFILE**

    source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '>= 5.0.0.beta2', '< 5.1'
#mongoid gem
gem 'mongoid', '~> 5.1.0'
# Use Puma as the app server
gem 'puma'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails mongoid

10
推荐指数
1
解决办法
3410
查看次数

处理 Knex pg 数据库错误的正确方法是什么

我使用 postgres 和 knex javascript 库来构建我的 sql 查询。我想处理来自 postgres 服务器的所有抛出的错误,因此我想要执行此操作的方法是检查抛出的错误的类型。

try {
   // knex query here
} catch(error) {
    if(error instanceof DatabaseError) {
      // handle pg error by checking error.code or something else
      // then send an custom error message to the client
    }

    // handle another error here which is not caused by the postgres server
}
Run Code Online (Sandbox Code Playgroud)

有什么办法可以处理这样的错误吗?

javascript postgresql error-handling knex.js

5
推荐指数
1
解决办法
7848
查看次数