diff --git a/errors/ServiceError.js b/errors/ServiceError.js new file mode 100644 index 0000000..27661e0 --- /dev/null +++ b/errors/ServiceError.js @@ -0,0 +1,32 @@ +class AccountsAPIError extends Error { + constructor(code, path, error, errorMessage) { + super(errorMessage || error || "Accounts API Error") + this.code = code + this.path = path + this.errorType = error + this.errorMessage = errorMessage + this.isOperational = true + + Error.captureStackTrace(this, this.constructor) + } + + serialize() { + const response = {} + + if (this.path && this.path.trim() !== "") { + response.path = this.path.replace(/:(\w+)/g, "<$1>") + } + + if (this.errorType && this.errorType.trim() !== "") { + response.error = this.errorType + } + + if (this.errorMessage && this.errorMessage.trim() !== "") { + response.errorMessage = this.errorMessage + } + + return response + } +} + +module.exports = AccountsAPIError \ No newline at end of file diff --git a/routes/minecraftservices/productvoucher.js b/routes/minecraftservices/productvoucher.js new file mode 100644 index 0000000..f4f48aa --- /dev/null +++ b/routes/minecraftservices/productvoucher.js @@ -0,0 +1,14 @@ +const express = require("express") +const router = express.Router() + +router.get("/giftcode", (req, res) => { + res.status(404).json({ + path: "/productvoucher/giftcode", + errorType: "NOT_FOUND", + error: "NOT_FOUND", + errorMessage: "The server has not found anything matching the request URI", + developerMessage: "The server has not found anything matching the request URI" + }) +}) + +module.exports = router \ No newline at end of file