fix: Add missing error causes

This commit is contained in:
Joachim Van Herwegen
2023-07-25 14:24:45 +02:00
parent f373dff1d7
commit 7505f07f2f
4 changed files with 9 additions and 5 deletions

View File

@@ -32,7 +32,7 @@ export class N3PatchBodyParser extends BodyParser {
try {
store = new Store(parser.parse(n3));
} catch (error: unknown) {
throw new BadRequestHttpError(`Invalid N3: ${createErrorMessage(error)}`);
throw new BadRequestHttpError(`Invalid N3: ${createErrorMessage(error)}`, { cause: error });
}
// Solid, §5.3.1: "A patch resource MUST contain a triple ?patch rdf:type solid:InsertDeletePatch."

View File

@@ -100,7 +100,8 @@ export class NotificationSubscriber extends OperationHttpHandler {
});
channel = await this.channelType.initChannel(await readableToQuads(quadStream.data), credentials);
} catch (error: unknown) {
throw new UnprocessableEntityHttpError(`Unable to process notification channel: ${createErrorMessage(error)}`);
throw new UnprocessableEntityHttpError(`Unable to process notification channel: ${createErrorMessage(error)}`,
{ cause: error });
}
if (this.maxDuration) {

View File

@@ -25,7 +25,8 @@ export async function fetchDataset(url: string): Promise<Representation> {
const quadArray = await arrayifyStream<Quad>(quadStream);
return new BasicRepresentation(quadArray, { path: url }, INTERNAL_QUADS, false);
} catch (error: unknown) {
throw new BadRequestHttpError(`Could not parse resource at URL (${url})! ${createErrorMessage(error)}`);
throw new BadRequestHttpError(`Could not parse resource at URL (${url})! ${createErrorMessage(error)}`,
{ cause: error });
}
})();
}

View File

@@ -112,7 +112,8 @@ export class FileSystemResourceLocker implements ResourceLocker, Initializable,
this.attemptSettings,
);
} catch (err: unknown) {
throw new InternalServerError(`Error trying to acquire lock for ${path}. ${createErrorMessage(err)}`);
throw new InternalServerError(`Error trying to acquire lock for ${path}. ${createErrorMessage(err)}`,
{ cause: err });
}
}
@@ -126,7 +127,8 @@ export class FileSystemResourceLocker implements ResourceLocker, Initializable,
this.attemptSettings,
);
} catch (err: unknown) {
throw new InternalServerError(`Error trying to release lock for ${path}. ${createErrorMessage(err)}`);
throw new InternalServerError(`Error trying to release lock for ${path}. ${createErrorMessage(err)}`,
{ cause: err });
}
}