Skip to content

Commit

Permalink
fix(core): Display informative message when saving a translatable fails
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Apr 26, 2021
1 parent d866325 commit ce6293d
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { DeepPartial } from '@vendure/common/lib/shared-types';

import { RequestContext } from '../../../api/common/request-context';
import { EntityNotFoundError } from '../../../common/error/errors';
import { InternalServerError } from '../../../common/error/errors';
import { Translatable, Translation, TranslationInput } from '../../../common/types/locale-types';
import { foundIn, not } from '../../../common/utils';
import { ProductOptionGroup } from '../../../entity/product-option-group/product-option-group.entity';
import { TransactionalConnection } from '../../transaction/transactional-connection';

export type TranslationContructor<T> = new (
Expand Down Expand Up @@ -72,9 +71,7 @@ export class TranslationDiffer<Entity extends Translatable> {
.getRepository(ctx, this.translationCtor)
.save(translation as any);
} catch (err) {
const entityName = entity.constructor.name;
const id = (entity as any).id || 'undefined';
throw new EntityNotFoundError(entityName as any, id);
throw new InternalServerError(err.message);
}
entity.translations.push(newTranslation);
}
Expand Down

0 comments on commit ce6293d

Please sign in to comment.