Skip to content

Commit a491b41

Browse files
committed
Account for RemoteFile implementation when reporting file location on error.
As suggested in #38.
1 parent eecf605 commit a491b41

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

bin/jsonld

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ def run(input, options)
6363
STDERR.puts "\nParsed #{num} statements in #{secs} seconds @ #{num/secs} statements/second." unless options[:quiet]
6464
end
6565
rescue
66-
fname = input.respond_to?(:path) ? input.path : "-stdin-"
66+
fname = case
67+
when input.respond_to?(:path) then input.path
68+
when input.respond_to?(:requested_url) && input.requested_url then input.requested_url
69+
when input.respond_to?(:base_uri) then input.base_uri
70+
else "-stdin-"
71+
end
6772
STDERR.puts("Error in #{fname}")
6873
raise
6974
end

example-files/mitar-in.jsonld

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"B": {"@context": {"c": "http://example.org/c"}}
5+
},
6+
"a": {
7+
"@context": {"@vocab": "http://example.com/"},
8+
"@type": "B",
9+
"a": "A in example.com",
10+
"c": "C in example.org"
11+
},
12+
"c": "C in example"
13+
}

0 commit comments

Comments
 (0)