rfm
rfm copied to clipboard
No raise even if raise_on_401 is set to true.
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
...
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