Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/errors/NamedGraphError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import type { Quad } from "@rdfjs/types"
*/
export class NamedGraphError extends QuadError {
constructor(quad: Quad, cause?: any) {
super(quad, `Graph must be default (empty) but was ${quad.value}`, cause)
super(quad, `Graph must be default (empty) but was ${quad.graph.value}`, cause)
}
}
10 changes: 10 additions & 0 deletions test/unit/named_graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ await describe("namedGraph", async () => {
)
})

await it("NamedGraphError message reports the offending graph IRI", () => {
const ds = new SomeDataset(storeWithNamedGraph(), DataFactory).namedGraph
const offendingGraph = DataFactory.namedNode("https://other.org/g")

assert.throws(
() => ds.add(DataFactory.quad(s, p, o, offendingGraph)),
(error: unknown) => error instanceof NamedGraphError && error.message.includes(offendingGraph.value),
)
})

await it("throws TermTypeError when matching with a non-default graph", () => {
const ds = new SomeDataset(storeWithNamedGraph(), DataFactory).namedGraph

Expand Down