fix: detect .json files in IFCLoader.load() with helpful error message#195
Open
TeapoyY wants to merge 1 commit intoThatOpen:mainfrom
Open
fix: detect .json files in IFCLoader.load() with helpful error message#195TeapoyY wants to merge 1 commit intoThatOpen:mainfrom
TeapoyY wants to merge 1 commit intoThatOpen:mainfrom
Conversation
… message Previously, when a user tried to load a JSON file (produced by the ifc-to-json tool) using IFCLoader.load(), the loader would attempt to parse it as a binary IFC file, resulting in a cryptic 'File too small' error from web-ifc. This change adds detection of .json URLs at the start of the load() method and throws a clear, actionable error message explaining: 1. That .json files cannot be loaded directly 2. That JSON files from ifc-to-json only contain property data, not geometry 3. That users should load the IFC file normally and then use addModelJSONData() for property data 4. A link to the documentation for the correct workflow Fixes ThatOpen#136 (bounty)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When users attempt to load a
.jsonfile (produced by theifc-to-jsontool) usingIFCLoader.load(), the loader previously attempted to parse it as a binary IFC file, resulting in a cryptic "File too small" error from web-ifc with no context about what went wrong.This PR adds detection of
.jsonURLs at the start of theload()method and throws a clear, actionable error message explaining the limitation and the correct workflow.The Bug
Issue: #136
Users converting IFC files to JSON using the
ifc-to-jsontool then trying to load the.jsonfile directly vialoadAsync(url)get an opaque error dialog "File too small" with no guidance on how to resolve it.The Fix
In
IFCLoader.load(), before loading, check if the URL ends with.json. If so, immediately invoke the error callback (or console.error) with a helpful message that:.jsonfiles cannot be loaded directlyifc-to-jsononly contain property/metadata (not geometry)addModelJSONData()for loading property data alongside an IFC fileBounty
This PR addresses #136 (labeled: bounty)