Skip to content

Commit ddf66fb

Browse files
committed
add error
1 parent 0e1b8a8 commit ddf66fb

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed

templates/cli/lib/type-generation/languages/dart.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class Dart extends LanguageMeta {
6262
break;
6363
case AttributeType.RELATIONSHIP:
6464
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
65+
if (!relatedCollection) {
66+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
67+
}
6568
type = LanguageMeta.toPascalCase(relatedCollection.name);
6669
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
6770
type = `List<${type}>`;

templates/cli/lib/type-generation/languages/java.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class Java extends LanguageMeta {
2525
break;
2626
case AttributeType.RELATIONSHIP:
2727
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
28+
if (!relatedCollection) {
29+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
30+
}
2831
type = LanguageMeta.toPascalCase(relatedCollection.name);
2932
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
3033
type = "List<" + type + ">";

templates/cli/lib/type-generation/languages/javascript.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class JavaScript extends LanguageMeta {
3030
break;
3131
case AttributeType.RELATIONSHIP:
3232
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
33+
if (!relatedCollection) {
34+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
35+
}
3336
type = LanguageMeta.toPascalCase(relatedCollection.name);
3437
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
3538
type = `${type}[]`;

templates/cli/lib/type-generation/languages/kotlin.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class Kotlin extends LanguageMeta {
2525
break;
2626
case AttributeType.RELATIONSHIP:
2727
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
28+
if (!relatedCollection) {
29+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
30+
}
2831
type = LanguageMeta.toPascalCase(relatedCollection.name);
2932
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
3033
type = `List<${type}>`;

templates/cli/lib/type-generation/languages/php.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class PHP extends LanguageMeta {
2828
break;
2929
case AttributeType.RELATIONSHIP:
3030
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
31+
if (!relatedCollection) {
32+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
33+
}
3134
type = LanguageMeta.toPascalCase(relatedCollection.name);
3235
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
3336
type = "array";

templates/cli/lib/type-generation/languages/swift.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class Swift extends LanguageMeta {
2525
break;
2626
case AttributeType.RELATIONSHIP:
2727
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
28+
if (!relatedCollection) {
29+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
30+
}
2831
type = LanguageMeta.toPascalCase(relatedCollection.name);
2932
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
3033
type = `[${type}]`;

templates/cli/lib/type-generation/languages/typescript.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class TypeScript extends LanguageMeta {
3030
break;
3131
case AttributeType.RELATIONSHIP:
3232
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
33+
if (!relatedCollection) {
34+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
35+
}
3336
type = LanguageMeta.toPascalCase(relatedCollection.name);
3437
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
3538
type = `${type}[]`;

0 commit comments

Comments
 (0)