Skip to content

Commit aa57afd

Browse files
committed
fix: improved error handling
1 parent baed308 commit aa57afd

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/index.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class CoCreateCrudServer {
7878

7979
let storages = this.storages.get(data.organization_id)
8080
if (storages === false)
81-
return resolve({ storage: false, error: 'A storage or database could not be found' })
81+
return resolve({ serverStorage: false, error: 'A storage or database could not be found' })
8282

8383
if (!storages) {
8484
if (data.organization_id === this.config.organization_id) {
@@ -93,17 +93,15 @@ class CoCreateCrudServer {
9393
object: [{ _id: data.organization_id }],
9494
organization_id: this.config.organization_id
9595
})
96-
if (organization && organization.object && organization.object[0])
97-
organization = organization.object[0]
98-
if (organization && organization.storage) {
99-
storages = organization.storage
100-
this.storages.set(data.organization_id, storages)
101-
} else {
102-
this.storages.set(data.organization_id, false)
103-
if (organization)
104-
return resolve({ storage: false, error: 'database url could not be found' })
96+
if (organization
97+
&& organization.object
98+
&& organization.object[0]) {
99+
if (organization.object[0].storage)
100+
this.storages.set(data.organization_id, organization.object[0].storage)
105101
else
106-
return resolve({ organization: false, error: 'organization could not be found' })
102+
return resolve({ serverStorage: false, error: 'A storage url could not be found' })
103+
} else {
104+
return resolve({ serverOrganization: false, error: 'An organization could not be found' })
107105
}
108106
}
109107
}

0 commit comments

Comments
 (0)