How to throw an exception with a status code? November 25, 2023 by Tarik You can use err.code const error = new Error("message") error.code = "YOUR_STATUS_CODE" throw error;