TypeError: Cannot read properties of undefined (reading 'write')
I am using
@sapphire/plugin-logger
.
I am building a provider to my database that currently uses the logging methods, I assumed it was because the client hadn't logged in yet so I moved my provider instantiation to the ReadyListener
.
This is my ReadyListener
at the moment
I can also confirm that the logger is functioning before the error
Solution:Jump to solution
Actually I figured it out,
```ts
const result = await model.create(document).catch((error) => {
container.logger.error(error);
});...
6 Replies
I am thinking, maybe when it runs the
insertDocument
method, if it fails it might crash the logger
Though it's annoying no other error appears before the logger so I don't knowSolution
Actually I figured it out,
Doing
.catch(container.logger.error)
will just absolutely obliterate the logger lmaoDo you separately import
container
or use this.container
?
Or you create a new instance of logger?
Because I tried all three and it still throws me such errorI import the container in this instance, what are you doing specifically?
I did:
1. Use
this.container.logger
2.
And had been importing this everywhere.
Both of them crashed whenever there was error and the logger was invoked/called
3. Now I use:
Which is working so far without logger itself crashing in any wayYea you are supposed to import it from framework and not the plugin itself