fix: imports + extra error type try and catch
This commit is contained in:
		
							parent
							
								
									219226148d
								
							
						
					
					
						commit
						2ac1b8187c
					
				
					 2 changed files with 4 additions and 3 deletions
				
			
		|  | @ -19,7 +19,8 @@ import { putObject } from './service-helper.js'; | |||
| import { fetchStudents } from './students.js'; | ||||
| import { ServerErrorException } from '../exceptions/server-error-exception.js'; | ||||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||
| import { ConflictException } from '../exceptions/conflict-exception'; | ||||
| import { ConflictException } from '../exceptions/conflict-exception.js'; | ||||
| import { PostgreSqlExceptionConverter } from "@mikro-orm/postgresql"; | ||||
| 
 | ||||
| export async function fetchAssignment(classid: string, assignmentNumber: number): Promise<Assignment> { | ||||
|     const classRepository = getClassRepository(); | ||||
|  | @ -138,7 +139,7 @@ export async function deleteAssignment(classid: string, id: number): Promise<Ass | |||
|     try { | ||||
|         await assignmentRepository.deleteByClassAndId(cls, id); | ||||
|     } catch (e: unknown) { | ||||
|         if (e instanceof ForeignKeyConstraintViolationException) { | ||||
|         if (e instanceof ForeignKeyConstraintViolationException || e instanceof PostgreSqlExceptionConverter) { | ||||
|             throw new ConflictException('Cannot delete assigment with questions or submissions'); | ||||
|         } else { | ||||
|             throw e; | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-requ | |||
| import { ConflictException } from '../exceptions/conflict-exception.js'; | ||||
| import { Submission } from '../entities/assignments/submission.entity.js'; | ||||
| import { mapToUsername } from '../interfaces/user.js'; | ||||
| import { mapToAssignmentDTO, mapToAssignmentDTOId } from '../interfaces/assignment'; | ||||
| import { mapToAssignmentDTO, mapToAssignmentDTOId } from '../interfaces/assignment.js'; | ||||
| 
 | ||||
| export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> { | ||||
|     const studentRepository = getStudentRepository(); | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl