Azure / azure-functions-nodejs-worker

The Node.js worker for the Azure Functions runtime - https://functions.azure.com
MIT License
106 stars 44 forks source link

Create setErrorMessage function #750

Closed castrodd closed 3 months ago

castrodd commented 3 months ago

This PR is a fix for Exception: Cannot set property message of [object Object] which has only a getter.

In February, we merged an earlier fix for this same issue (#732).

However, @ryanbecker reported a problem with our initial approach.

Therefore, we have rolled back those changes and instead take a simpler approach. Everywhere we previously tried to write to error.message, we now catch any exceptions thrown by read-only errors. In those cases, we simply return the original error and do not attempt to modify its error message.