Added a better error handling

This commit is contained in:
2025-12-20 15:48:57 +01:00
parent f6f4a249c1
commit 18efd445e5
4 changed files with 51 additions and 16 deletions

View File

@@ -1,22 +1,15 @@
const crypto = require("node:crypto")
const DefaultError = require("../errors/DefaultError")
function register({ email, username, password }) {
if (true) {
return {
code: 200,
message: "User successfully registered",
data: {
id: crypto.randomUUID(),
username: username,
email: email
}
id: crypto.randomUUID(),
username: username,
email: email
}
} else {
return {
code: 418,
error: "I'm a tea pot",
message: "Error occured",
}
throw new DefaultError(418, "I'm a teapot", "", "TeaPotExeception")
}
}