Skip to content
Open
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
16 changes: 15 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app } from 'mu';
import { app, errorHandler } from 'mu';
import services from './config/rules';
import normalizeQuad from './config/normalize-quad';
import bodyParser from 'body-parser';
Expand Down Expand Up @@ -88,6 +88,20 @@ async function informWatchers( changeSets, res, muCallIdTrail, muSessionId ){
} );
}

app.use((err, req, res, next) => {
if (err.type === 'entity.too.large') {
console.warn(`Payload too large for ${req.method} ${req.originalUrl}`);
return res.status(413).json({
errors: [ {title: 'Payload too large'} ]
});
}

// Pass other errors to the default handler
next(err);
});

app.use(errorHandler);

function tripleMatchesSpec( triple, matchSpec ) {
// form of triple is {s, p, o}, same as matchSpec
if( process.env["DEBUG_TRIPLE_MATCHES_SPEC"] )
Expand Down