Skip to content

Commit bd62280

Browse files
committed
Throw custom exception from unimplemented stubs
1 parent 9091bbd commit bd62280

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+160
-132
lines changed

include/graphqlservice/GraphQLService.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ class [[nodiscard]] schema_exception : public std::exception
107107
std::list<schema_error> _structuredErrors;
108108
};
109109

110+
// This exception is thrown when an generated stub is called for an unimplemented method.
111+
class [[nodiscard]] unimplemented_method : public std::runtime_error
112+
{
113+
public:
114+
GRAPHQLSERVICE_EXPORT explicit unimplemented_method(std::string_view methodName);
115+
116+
unimplemented_method() = delete;
117+
118+
private:
119+
static GRAPHQLSERVICE_EXPORT std::string getMessage(std::string_view methodName) noexcept;
120+
};
121+
110122
// The RequestState is nullable, but if you have multiple threads processing requests and there's
111123
// any per-request state that you want to maintain throughout the request (e.g. optimizing or
112124
// batching backend requests), you can inherit from RequestState and pass it to Request::resolve to

samples/today/nointrospection/AppointmentConnectionObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class [[nodiscard]] AppointmentConnection final
9292
}
9393
else
9494
{
95-
throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex");
95+
throw service::unimplemented_method(R"ex(AppointmentConnection::getPageInfo)ex");
9696
}
9797
}
9898

@@ -108,7 +108,7 @@ class [[nodiscard]] AppointmentConnection final
108108
}
109109
else
110110
{
111-
throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex");
111+
throw service::unimplemented_method(R"ex(AppointmentConnection::getEdges)ex");
112112
}
113113
}
114114

samples/today/nointrospection/AppointmentEdgeObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class [[nodiscard]] AppointmentEdge final
9292
}
9393
else
9494
{
95-
throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex");
95+
throw service::unimplemented_method(R"ex(AppointmentEdge::getNode)ex");
9696
}
9797
}
9898

@@ -108,7 +108,7 @@ class [[nodiscard]] AppointmentEdge final
108108
}
109109
else
110110
{
111-
throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex");
111+
throw service::unimplemented_method(R"ex(AppointmentEdge::getCursor)ex");
112112
}
113113
}
114114

samples/today/nointrospection/AppointmentObject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class [[nodiscard]] Appointment final
141141
}
142142
else
143143
{
144-
throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex");
144+
throw service::unimplemented_method(R"ex(Appointment::getId)ex");
145145
}
146146
}
147147

@@ -157,7 +157,7 @@ class [[nodiscard]] Appointment final
157157
}
158158
else
159159
{
160-
throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex");
160+
throw service::unimplemented_method(R"ex(Appointment::getWhen)ex");
161161
}
162162
}
163163

@@ -173,7 +173,7 @@ class [[nodiscard]] Appointment final
173173
}
174174
else
175175
{
176-
throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex");
176+
throw service::unimplemented_method(R"ex(Appointment::getSubject)ex");
177177
}
178178
}
179179

@@ -189,7 +189,7 @@ class [[nodiscard]] Appointment final
189189
}
190190
else
191191
{
192-
throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex");
192+
throw service::unimplemented_method(R"ex(Appointment::getIsNow)ex");
193193
}
194194
}
195195

@@ -205,7 +205,7 @@ class [[nodiscard]] Appointment final
205205
}
206206
else
207207
{
208-
throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex");
208+
throw service::unimplemented_method(R"ex(Appointment::getForceError)ex");
209209
}
210210
}
211211

samples/today/nointrospection/CompleteTaskPayloadObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class [[nodiscard]] CompleteTaskPayload final
9292
}
9393
else
9494
{
95-
throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex");
95+
throw service::unimplemented_method(R"ex(CompleteTaskPayload::getTask)ex");
9696
}
9797
}
9898

@@ -108,7 +108,7 @@ class [[nodiscard]] CompleteTaskPayload final
108108
}
109109
else
110110
{
111-
throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex");
111+
throw service::unimplemented_method(R"ex(CompleteTaskPayload::getClientMutationId)ex");
112112
}
113113
}
114114

samples/today/nointrospection/ExpensiveObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class [[nodiscard]] Expensive final
7878
}
7979
else
8080
{
81-
throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex");
81+
throw service::unimplemented_method(R"ex(Expensive::getOrder)ex");
8282
}
8383
}
8484

samples/today/nointrospection/FolderConnectionObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class [[nodiscard]] FolderConnection final
9292
}
9393
else
9494
{
95-
throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex");
95+
throw service::unimplemented_method(R"ex(FolderConnection::getPageInfo)ex");
9696
}
9797
}
9898

@@ -108,7 +108,7 @@ class [[nodiscard]] FolderConnection final
108108
}
109109
else
110110
{
111-
throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex");
111+
throw service::unimplemented_method(R"ex(FolderConnection::getEdges)ex");
112112
}
113113
}
114114

samples/today/nointrospection/FolderEdgeObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class [[nodiscard]] FolderEdge final
9292
}
9393
else
9494
{
95-
throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex");
95+
throw service::unimplemented_method(R"ex(FolderEdge::getNode)ex");
9696
}
9797
}
9898

@@ -108,7 +108,7 @@ class [[nodiscard]] FolderEdge final
108108
}
109109
else
110110
{
111-
throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex");
111+
throw service::unimplemented_method(R"ex(FolderEdge::getCursor)ex");
112112
}
113113
}
114114

samples/today/nointrospection/FolderObject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class [[nodiscard]] Folder final
113113
}
114114
else
115115
{
116-
throw std::runtime_error(R"ex(Folder::getId is not implemented)ex");
116+
throw service::unimplemented_method(R"ex(Folder::getId)ex");
117117
}
118118
}
119119

@@ -129,7 +129,7 @@ class [[nodiscard]] Folder final
129129
}
130130
else
131131
{
132-
throw std::runtime_error(R"ex(Folder::getName is not implemented)ex");
132+
throw service::unimplemented_method(R"ex(Folder::getName)ex");
133133
}
134134
}
135135

@@ -145,7 +145,7 @@ class [[nodiscard]] Folder final
145145
}
146146
else
147147
{
148-
throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex");
148+
throw service::unimplemented_method(R"ex(Folder::getUnreadCount)ex");
149149
}
150150
}
151151

samples/today/nointrospection/MutationObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class [[nodiscard]] Mutation final
9292
}
9393
else
9494
{
95-
throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex");
95+
throw service::unimplemented_method(R"ex(Mutation::applyCompleteTask)ex");
9696
}
9797
}
9898

@@ -108,7 +108,7 @@ class [[nodiscard]] Mutation final
108108
}
109109
else
110110
{
111-
throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex");
111+
throw service::unimplemented_method(R"ex(Mutation::applySetFloat)ex");
112112
}
113113
}
114114

0 commit comments

Comments
 (0)