Skip to content

feat(fastify-rdf): add reply.sendHydraError() for Hydra error responses#189

Merged
ddeboer merged 1 commit intomainfrom
feat/fastify-rdf-hydra-error
Mar 2, 2026
Merged

feat(fastify-rdf): add reply.sendHydraError() for Hydra error responses#189
ddeboer merged 1 commit intomainfrom
feat/fastify-rdf-hydra-error

Conversation

@ddeboer
Copy link
Member

@ddeboer ddeboer commented Mar 2, 2026

Summary

Add reply.sendHydraError(error) to @lde/fastify-rdf for sending Hydra error responses with content negotiation.

  • Maps error.message to hydra:title and string error.cause to hydra:description
  • Status code from error.statusCode, defaulting to 500
  • For application/ld+json: returns compact JSON-LD directly — no jsonld dependency needed
  • For all other RDF formats: builds an N3 Store and serialises through the existing pipeline
  • Exports createHydraErrorDataset for consumer test assertions

Fix #186

Test plan

  • npx nx test fastify-rdf — 36 tests pass (9 hydra-error unit + 27 plugin integration)
  • npx nx lint fastify-rdf — clean
  • npx nx typecheck fastify-rdf — clean
  • npx nx build fastify-rdf — clean

- Add serializeHydraErrorAsJsonLd() for compact JSON-LD without jsonld dep
- Add createHydraErrorDataset() to build N3 Store with Hydra error triples
- Register sendHydraError decorator with content negotiation support
- Map error.message → hydra:title, string error.cause → hydra:description
- Export createHydraErrorDataset for consumer test assertions
- Add unit tests for pure functions and integration tests for the decorator
@ddeboer ddeboer merged commit a8fba6a into main Mar 2, 2026
2 checks passed
@ddeboer ddeboer deleted the feat/fastify-rdf-hydra-error branch March 2, 2026 19:16
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.

Add Hydra error response support to fastify-rdf

1 participant