Skip to content

Commit

Permalink
Media Upload failure provides a reason.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmoy12c committed Oct 6, 2023
1 parent a490eaf commit a6ccd0f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modules/form/form.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class FormController {
async single(
@UploadedFiles() files: {form: Express.Multer.File[], mediaFiles: Express.Multer.File[]},
) {
if (!files.form[0]) {
if (!files.form || !files.form[0]) {
throw new BadRequestException('Form file is required!');
}
const response = await this.formService.uploadForm(files.form[0], files.mediaFiles);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/form/form.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('FormService', () => {

expect(formService.uploadForm(mockXmlFile, mockMediaFiles))
.rejects
.toThrowError(new ServiceUnavailableException('Media upload failed!'));
.toThrowError(new ServiceUnavailableException('Media upload failed! Reason: Error'));
});

it('form upload throws service unavailable exception when ODK server is unavailable', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/form/form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class FormService {
const mediaUploadResult = await this.uploadFormMediaFiles(mediaFiles);
if (mediaUploadResult.error || !mediaUploadResult.data) {
this.logger.error(`FormService::uploadForm: Media Files upload failed!`);
throw new ServiceUnavailableException('Media upload failed!');
throw new ServiceUnavailableException(`Media upload failed! Reason: ${mediaUploadResult.error}`);
}
const xmlModificationError = this.replaceMediaFileName(formFile, mediaUploadResult.data);
if (xmlModificationError != '') {
Expand Down

0 comments on commit a6ccd0f

Please sign in to comment.