Throw better error for incorrect config
See original GitHub issueI get this error:
TypeError: Cannot read property 'collection' of undefined
at /srv/node_modules/integrify/lib/rules/replicateAttributes.js:61:18
at Array.forEach (<anonymous>)
at /srv/node_modules/integrify/lib/rules/replicateAttributes.js:47:22
at cloudFunctionNewSignature (/srv/node_modules/firebase-functions/lib/cloud-functions.js:105:23)
at /worker/worker.js:825:24
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
I have the following Firebase Cloud Function running in Node 8 environment with Typescript code:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
const { integrify } = require('integrify');
admin.initializeApp();
const firestore = admin.firestore();
integrify({ config: { functions, firestore } });
exports.inventory_item_replicate = integrify({
rule: 'REPLICATE_ATTRIBUTES',
source: {
collection: 'inventory_item',
},
targets: [
{
collection: 'cart',
foreignKey: 'id',
attributeMapping: {
'barcode': 'barcode',
'category': 'category',
'image': 'image',
'name': 'name',
'price': 'price',
'stock': 'stock',
'type': 'type',
},
},
],
});
The replication function seems to fire correctly after an update on the original collection, as I can see from the logs, and the error is logged directly afterwards:
integrify: Detected update in [inventory_item], id [QmNKvERKZI3HFEyKz3Ft],
new value: { ...
...
...
...
integrify: On collection [cart], applying update: { ....
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - What exception should I throw if a configuration value is ...
I would like to throw the error in the static methods that use these values, but ArgumentNullException doesn't seem right as they are...
Read more >Throw warning on invalid config #250 - laravel/ideas - GitHub
So simply looking for a null config item is not the same as no config item found . What I am saying is...
Read more >5.3. Choosing when to Throw a Particular Exception - O'Reilly
Thrown when a parameter value for a method is null and null is not allowed. Thrown when a parameter value for a method...
Read more >Best Practices for exceptions - .NET - Microsoft Learn
Throw an ArgumentException exception or one of the predefined classes that derive from ArgumentException if invalid parameters are passed.
Read more >How to Throw Exceptions in Java - Rollbar
Checked exceptions are generally caused by faults outside code like missing files, invalid class names, and networking errors. FileInputStream ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @RamiYahyaRY thanks for trying out
integrify
!Could you edit the configuration line thus:
integrify
expects two keys in theconfig
object:functions
anddb
.LMK if it works. I can enhance it to throw better error message.
@devth lets continue this discussion at #56