import { type QueryFailedError } from 'typeorm'; import { CommonQueryRunnerException } from 'src/engine/api/common/common-query-runners/errors/common-query-runner.exception'; import { commonQueryRunnerToRestApiExceptionHandler } from 'src/engine/api/common/common-query-runners/utils/common-query-runner-to-rest-api-exception-handler.util'; interface QueryFailedErrorWithCode extends QueryFailedError { code: string; } export const workspaceQueryRunnerRestApiExceptionHandler = ( error: QueryFailedErrorWithCode, ): never => { switch (true) { case error instanceof CommonQueryRunnerException: return commonQueryRunnerToRestApiExceptionHandler(error); default: throw error; } };