cloudinary-community / cloudinary-community/next-cloudinary

e is not defined, should be [e.message -> error.message] in page/api

Open
#612 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
300
Forks
137
Avg merge
3m
Merged PRs (30d)
2

Description

# **Bug Report**

## **Describe the bug**
In the Cloudinary API signature handler file, there is a variable mismatch inside the catch block. The catch clause defines the error variable as error, but inside the block, it references e.message instead of error.message. This causes a ReferenceError when the code tries to handle an exception.

```
ReferenceError: e is not defined

```

/pages/api/signature.js (or wherever this handler file is located)

## **Steps To Reproduce the error**

💡 Steps to Reproduce

1. Trigger any condition that causes the try block to fail (for example, invalid Cloudinary credentials).

2. Observe that instead of returning a proper error response, the server crashes or returns a 500 error with the message e is not defined.

🛠️ Proposed Fix

Replace:
```
catch (error) {
res.status(500).json({
error: e.message,
});
}
```
with:
```
catch (error) {
res.status(500).json({
error: error.message,
});
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.