Skip to content

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

@mukeshdhadhariya

Description

@mukeshdhadhariya

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,
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions