Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No raise even if raise_on_401 is set to true. #47

Open
takeshi0206 opened this issue May 4, 2020 · 1 comment
Open

No raise even if raise_on_401 is set to true. #47

takeshi0206 opened this issue May 4, 2020 · 1 comment

Comments

@takeshi0206
Copy link

takeshi0206 commented May 4, 2020

ginjo-rfm-3.0.12
Rails 6.0.2.2

When executing the Find method, no exception is thrown if there is no such record.

sample code


Models / art.rb

class Art < Rfm::Base
  config :layout => 'English_Form_View',
   :host => "127.0.0.1",
   :port => 16020,
   :account_name => "admin",
   :password => "xxxxxxxx",
   :database => "FMServer_Sample",
   :raise_on_401 => true,
   :ssl => false
end


Controllers / art_controller.rb

class ArtController < ApplicationController
...
  def search
    begin
        @records = Art.find "TextForSearch" => params[:Search]
        flash[:notice] = Art.config[:raise_on_401]  # true
      end
    rescue Rfm::Error::NoRecordsFoundError
      flash[:notice] = "'#{params[:Search]}' could not be found.”
      @records = Art.all
    end
  end
...
@takeshi0206
Copy link
Author

In resultset.rb, it says raise_401.

resultset.rb

private

def check_for_errors(error_code=@meta['error'].to_i, raise_401=state[:raise_401])
  puts ["\nRESULTSET#check_for_errors", "meta[:error] #{@meta[:error]}", "error_code: #{error_code}", "raise_401: #{raise_401}"]
  raise Rfm::Error.getError(error_code) if error_code != 0 && (error_code != 401 || raise_401)
end

However, in config.rb, it is written as raise_on_401. Is this the cause?

Before changing config.rb

  module Config
    require 'yaml'
    require 'erb'

    CONFIG_KEYS = %w(
      file_name
      file_path
      parser
      host
      port
      proxy
      account_name
      password
      database
      layout
      ignore_bad_data
      ssl
      root_cert
      root_cert_name
      root_cert_path
      warn_on_redirect
      raise_on_401
      timeout
      log_actions
      log_responses
      log_parser
      use
      parent
      template
      grammar
      field_mapping
      capture_strings_with
      logger
      decimal_separator
    )

If you use raise_401 in accordance with resultset.rb, exceptions can be picked up.

After changing config.rb

  module Config
    require 'yaml'
    require 'erb'

    CONFIG_KEYS = %w(
      file_name
      file_path
      parser
      host
      port
      proxy
      account_name
      password
      database
      layout
      ignore_bad_data
      ssl
      root_cert
      root_cert_name
      root_cert_path
      warn_on_redirect
      raise_401
      timeout
      log_actions
      log_responses
      log_parser
      use
      parent
      template
      grammar
      field_mapping
      capture_strings_with
      logger
      decimal_separator
    )

After changing art.rb

require 'active_model'

class Art < Rfm::Base
  config :layout => 'English_Form_View',
   :host => "127.0.0.1",
   :port => 16020,
   :account_name => "admin",
   :password => “xxxxxxxx”,
   :database => "FMServer_Sample",
   :raise_401 => true,
   :ssl => false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant