Skip to content

Commit

Permalink
feat: Handle triple store write errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Dec 1, 2023
1 parent 6087a9d commit 341bd80
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 10 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
global: {
lines: 24.48,
statements: 24.48,
branches: 13.88,
branches: 13.15,
functions: 23.52,
},
},
Expand Down
80 changes: 76 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@netwerk-digitaal-erfgoed/network-of-terms-catalog": "^8.0.0",
"@netwerk-digitaal-erfgoed/network-of-terms-query": "^4.0.0",
"asynciterator": "^3.8.1",
"axios": "^1.6.2",
"env-schema": "^5.2.1",
"filenamify-url": "^3.0.0",
"graphdb": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Pipeline {
}
if (store.size > 0) {
for (const writer of this.config.writers) {
writer.write(dataset, store);
await writer.write(dataset, store);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {Dataset} from './dataset.js';
import filenamifyUrl from 'filenamify-url';

export interface SummaryWriter {
write(dataset: Dataset, summary: DatasetCore): void;
write(dataset: Dataset, summary: DatasetCore): Promise<void>;
}

export class FileWriter implements SummaryWriter {
write(dataset: Dataset, summary: DatasetCore): void {
async write(dataset: Dataset, summary: DatasetCore): Promise<void> {
const writer = new Writer({
prefixes: {
void: 'http://rdfs.org/ns/void#',
Expand Down
9 changes: 7 additions & 2 deletions src/writer/sparql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import {DatasetCore} from 'rdf-js';
import {Dataset} from '../dataset.js';
import graphdb from 'graphdb';
import RDFRepositoryClient from 'graphdb/lib/repository/rdf-repository-client.js';
import {AxiosError} from 'axios';

export class SparqlWriter implements SummaryWriter {
constructor(private sparqlClient: SparqlClient) {}

write(dataset: Dataset, summary: DatasetCore): void {
async write(dataset: Dataset, summary: DatasetCore): Promise<void> {
this.sparqlClient.store(dataset, summary);
}
}
Expand Down Expand Up @@ -37,7 +38,11 @@ export class GraphDBClient implements SparqlClient {
try {
await this.repository.putQuads([...summary], dataset.iri);
} catch (e) {
console.error('write failed', (e as Error).message);
console.error(
'Write to GraphDB failed for dataset ' + dataset.iri,
(e as AxiosError).message,
(e as AxiosError).response?.data
);
}
}
}

0 comments on commit 341bd80

Please sign in to comment.