Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Standardize error handling in role-permissions.util.js #4440

Open
coderabbitai bot opened this issue Feb 16, 2025 · 0 comments
Open

Refactor: Standardize error handling in role-permissions.util.js #4440

coderabbitai bot opened this issue Feb 16, 2025 · 0 comments
Assignees

Comments

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2025

Background

Currently, there are inconsistent patterns for error handling in role-permissions.util.js. The new getDefaultGroupRole function uses throw new HttpError while other functions use next(new HttpError).

Proposed Change

Standardize error handling across all functions to use throw new HttpError pattern:

 } catch (error) {
   logger.error(`🐛🐛 Internal Server Error ${error.message}`);
-  next(
-    new HttpError(
-      "Internal Server Error",
-      httpStatus.INTERNAL_SERVER_ERROR,
-      { message: error.message }
-    )
-  );
+  throw new HttpError(
+    "Internal Server Error",
+    httpStatus.INTERNAL_SERVER_ERROR,
+    { message: error.message }
+  );
 }

Benefits

  • Consistent error handling pattern throughout the file
  • Cleaner error propagation
  • Better alignment with JavaScript's error handling mechanisms

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant