Skip to content

Commit 2c6c00b

Browse files
committed
errs
1 parent 1d69529 commit 2c6c00b

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

incl/Avalanche.hpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pragma once
12
#ifndef AVALANCHE_HPP
23
#define AVALANCHE_HPP
34

@@ -148,15 +149,15 @@ namespace avalanche { // Avalanche Index mod namespace
148149
Project() = default; // Default empty constructor
149150
};
150151

151-
class Handler {
152+
struct Handler {
152153
public:
153154
// Get the Handler functions
154155
static Handler* get() {
155156
static Handler ptr;
156157
return &ptr;
157158
};
158159

159-
class Badges {
160+
struct Badges {
160161
public:
161162
// Get the node ID from the badge type enum
162163
static const char* getBadgeID(Profile::Badge badge);
@@ -174,7 +175,7 @@ namespace avalanche { // Avalanche Index mod namespace
174175
static constexpr const char* apiToBadgeID(const std::string& apiName);
175176
};
176177

177-
class Levels {
178+
struct Levels {
178179
public:
179180
// Get the project type enum from the API code
180181
static Project::Type fromString(const std::string& str);
@@ -184,20 +185,24 @@ namespace avalanche { // Avalanche Index mod namespace
184185
};
185186

186187
// Fetch all remote data on badges and levels, automatically checks "Fetch Data Once" setting
187-
void scanAll();
188+
static void scanAll();
188189

189190
// Get profile data on a player
190-
Profile GetProfile(int id);
191+
static Profile GetProfile(
192+
int id // The player's account ID
193+
);
191194
// Get project data on a level
192-
Project GetProject(int id);
195+
static Project GetProject(
196+
int id // The level's ID
197+
);
193198

194199
// Check if the profile belongs to a team member
195-
bool isTeamMember(Profile::Badge badge);
200+
static bool isTeamMember(Profile::Badge badge);
196201

197202
// Get the comment text color for a certain badge type
198-
ccColor3B getCommentColor(Profile::Badge badge);
203+
static ccColor3B getCommentColor(Profile::Badge badge);
199204

200-
void getBadgeInfo(Profile::Badge badge);
205+
static void getBadgeInfo(Profile::Badge badge);
201206
void onInfoBadge(CCObject* sender);
202207

203208
// Create badge and format comment for a player

incl/src/Avalanche.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,11 @@ namespace avalanche {
126126
if (avalReqRes->json().isOk()) {
127127
auto jsonRes = avalReqRes->json().unwrapOr(Value::object());
128128

129-
if (jsonRes.contains("error")) {
130-
log::error("Profile API request returned error object");
129+
if (jsonRes.contains("error")) { // if cubic's api returns an error object
130+
auto errMsg = jsonRes["error"].asString().unwrapOr(und);
131+
auto errCode = jsonRes["http_code"].asInt().unwrapOr(404);
132+
133+
log::error("[{}] Profile API request returned error: {}", errCode, errMsg);
131134
jsonRes = Value::object();
132135
} else {
133136
for (auto& [key, value] : jsonRes) {
@@ -166,8 +169,11 @@ namespace avalanche {
166169
if (avalReqRes->json().isOk()) {
167170
auto jsonRes = avalReqRes->json().unwrapOr(Value::object());
168171

169-
if (jsonRes.contains("error")) {
170-
log::error("Project API request returned error object");
172+
if (jsonRes.contains("error")) { // if cubic's api returns an error object
173+
auto errMsg = jsonRes["error"].asString().unwrapOr(und);
174+
auto errCode = jsonRes["http_code"].asInt().unwrapOr(404);
175+
176+
log::error("[{}] Project API request returned error: {}", errCode, errMsg);
171177
jsonRes = Value::object();
172178
} else {
173179
for (auto& [key, value] : jsonRes) {

0 commit comments

Comments
 (0)