Skip to content

#577 Rescue PMP type conversion errors with Fbe::Error#614

Open
VasilevNStas wants to merge 4 commits into
zerocracy:masterfrom
VasilevNStas:577-pmp-type-conversion
Open

#577 Rescue PMP type conversion errors with Fbe::Error#614
VasilevNStas wants to merge 4 commits into
zerocracy:masterfrom
VasilevNStas:577-pmp-type-conversion

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

Problem

When a PMP property value or default is non-numeric (e.g., "abc") but the schema declares type: int or type: float, Integer()/Float() raises ArgumentError which propagates as an unhelpful crash.

Solution

Wrapped both the default value conversion (XML defaults) and the result value conversion (factbase query) in begin/rescue blocks. If ArgumentError or TypeError occurs, a descriptive Fbe::Error is raised with details about the property, area, and offending value.

Closes #577

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 please review this

Comment thread lib/fbe/pmp.rb Outdated
else default
end
rescue ArgumentError, TypeError => e
msg = "Invalid default value '#{default}' for PMP property '#{param}' in area '#{area}': #{e.message}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VasilevNStas can't we inline this var?

@VasilevNStas VasilevNStas left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256

Inlined
plz review

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

Successfully merging this pull request may close these issues.

PMP type conversion crashes on non-numeric values without error handling

2 participants