Explicitly set catch parameters to any type (#7654)

This fixes not being able to build the repo due to type issues
introduced by the Typescript 4.4 option "useUnknownInCatchVariables",
which is enabled by default in strict mode.
This commit is contained in:
Nicola Krumschmidt
2021-08-27 16:33:30 +02:00
committed by GitHub
parent 114dd5e3e3
commit d64ca14348
133 changed files with 266 additions and 266 deletions

View File

@@ -99,7 +99,7 @@ router.post(
res.locals.payload = {
data: record || null,
};
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -138,7 +138,7 @@ router.patch(
res.locals.payload = {
data: record || null,
};
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -177,7 +177,7 @@ router.post(
try {
await service.requestPasswordReset(req.body.email, req.body.reset_url || null);
return next();
} catch (err) {
} catch (err: any) {
if (err instanceof InvalidPayloadException) {
throw err;
} else {
@@ -320,7 +320,7 @@ router.get(
authResponse = await authenticationService.authenticate({
email,
});
} catch (error) {
} catch (error: any) {
emitStatus('fail');
logger.warn(error);

View File

@@ -88,7 +88,7 @@ router.patch(
try {
const collection = await collectionsService.readOne(req.params.collection);
res.locals.payload = { data: collection || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -101,7 +101,7 @@ router.post(
try {
const createdField = await service.readOne(req.params.collection, field.field);
res.locals.payload = { data: createdField || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -138,7 +138,7 @@ router.patch(
results.push(updatedField);
res.locals.payload = { data: results || null };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -193,7 +193,7 @@ router.patch(
try {
const updatedField = await service.readOne(req.params.collection, req.params.field);
res.locals.payload = { data: updatedField || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -73,7 +73,7 @@ const multipartHandler = asyncHandler(async (req, res, next) => {
const primaryKey = await service.uploadOne(fileStream, payloadWithRequiredFields, existingPrimaryKey);
savedFiles.push(primaryKey);
tryDone();
} catch (error) {
} catch (error: any) {
busboy.emit('error', error);
}
});
@@ -127,7 +127,7 @@ router.post(
data: record,
};
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -164,7 +164,7 @@ router.post(
try {
const record = await service.readOne(primaryKey, req.sanitizedQuery);
res.locals.payload = { data: record || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -242,7 +242,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -269,7 +269,7 @@ router.patch(
try {
const record = await service.readOne(req.params.pk, req.sanitizedQuery);
res.locals.payload = { data: record || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -37,7 +37,7 @@ router.post(
const record = await service.readOne(savedKeys[0], req.sanitizedQuery);
res.locals.payload = { data: record };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -114,7 +114,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -140,7 +140,7 @@ router.patch(
try {
const record = await service.readOne(primaryKey, req.sanitizedQuery);
res.locals.payload = { data: record || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -42,7 +42,7 @@ router.post(
const result = await service.readOne(savedKeys[0], req.sanitizedQuery);
res.locals.payload = { data: result || null };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -144,7 +144,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -177,7 +177,7 @@ router.patch(
try {
const result = await service.readOne(updatedPrimaryKey, req.sanitizedQuery);
res.locals.payload = { data: result || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -20,7 +20,7 @@ const notFound: RequestHandler = async (req, res, next) => {
return next();
}
next(new RouteNotFoundException(req.path));
} catch (err) {
} catch (err: any) {
next(err);
}
};

View File

@@ -37,7 +37,7 @@ router.post(
const item = await service.readOne(savedKeys[0], req.sanitizedQuery);
res.locals.payload = { data: item };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -116,7 +116,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -142,7 +142,7 @@ router.patch(
try {
const item = await service.readOne(primaryKey, req.sanitizedQuery);
res.locals.payload = { data: item || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -37,7 +37,7 @@ router.post(
const record = await service.readOne(savedKeys[0], req.sanitizedQuery);
res.locals.payload = { data: record };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -115,7 +115,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -141,7 +141,7 @@ router.patch(
try {
const record = await service.readOne(primaryKey, req.sanitizedQuery);
res.locals.payload = { data: record };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -90,7 +90,7 @@ router.post(
try {
const createdRelation = await service.readOne(req.body.collection, req.body.field);
res.locals.payload = { data: createdRelation || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -135,7 +135,7 @@ router.patch(
try {
const updatedField = await service.readOne(req.params.collection, req.params.field);
res.locals.payload = { data: updatedField || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -37,7 +37,7 @@ router.post(
const item = await service.readOne(savedKeys[0], req.sanitizedQuery);
res.locals.payload = { data: item };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -106,7 +106,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -132,7 +132,7 @@ router.patch(
try {
const item = await service.readOne(primaryKey, req.sanitizedQuery);
res.locals.payload = { data: item || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -35,7 +35,7 @@ router.patch(
try {
const record = await service.readSingleton(req.sanitizedQuery);
res.locals.payload = { data: record || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -38,7 +38,7 @@ router.post(
const item = await service.readOne(savedKeys[0], req.sanitizedQuery);
res.locals.payload = { data: item };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -86,7 +86,7 @@ router.get(
try {
const item = await service.readOne(req.accountability.user, req.sanitizedQuery);
res.locals.payload = { data: item || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
res.locals.payload = { data: { id: req.accountability.user } };
return next();
@@ -177,7 +177,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -203,7 +203,7 @@ router.patch(
try {
const item = await service.readOne(primaryKey, req.sanitizedQuery);
res.locals.payload = { data: item || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}

View File

@@ -103,7 +103,7 @@ router.post(
busboy.on('file', async (fieldname, fileStream, filename, encoding, mimetype) => {
try {
await service.import(req.params.collection, mimetype, fileStream);
} catch (err) {
} catch (err: any) {
return next(err);
}

View File

@@ -37,7 +37,7 @@ router.post(
const item = await service.readOne(savedKeys[0], req.sanitizedQuery);
res.locals.payload = { data: item };
}
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -106,7 +106,7 @@ router.patch(
try {
const result = await service.readMany(keys, req.sanitizedQuery);
res.locals.payload = { data: result };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}
@@ -132,7 +132,7 @@ router.patch(
try {
const item = await service.readOne(primaryKey, req.sanitizedQuery);
res.locals.payload = { data: item || null };
} catch (error) {
} catch (error: any) {
if (error instanceof ForbiddenException) {
return next();
}