Back

[SOLVED]context.error does not log the error content

  • 0
  • Functions
Osman
22 Sep, 2023, 18:52

When i execute the following code(NodeJS runtime), using the context.error or context.log functions to log the error, it logs an empty object instead of the actual error.

TypeScript
      await asyncFunc()
    }
    catch(err) {
      console.log(err)
      error(err)
      return res.empty()
  }```

Old fashioned console.log() logs the error just fine though.
TL;DR
Title: [SOLVED] context.error not logging error content Issue: When using context.error or context.log to log an error, it logs an empty object instead of the actual error content. Solution: Use err.toString() instead of trying to stringify objects. Code example: ``` try { await asyncFunc() } catch(err) { console.log(err) error(err.toString()) return res.empty() } ``` Using console.log() instead of context.error or context.log works fine.
Drake
22 Sep, 2023, 21:42

Open Runtimes tries to stringify objects but that doesn't work on errors. You should do err.toString() instead.

Osman
23 Sep, 2023, 09:08

Thanks <:appwritefire:823999000330895380>

Osman
23 Sep, 2023, 09:10

[SOLVED]context.error does not log the error content

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more