Skip to content

Commit cbc6804

Browse files
committed
Check to see if 400 error is validation error (invalid_field)
1 parent 74c99fa commit cbc6804

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ function sendRequest<T>(options: request.UriOptions) {
2828
const firstErr = (data.errors && Array.isArray(data.errors) && data.errors.length !== 0) ? data.errors[0] : undefined;
2929
switch (response.statusCode) {
3030
case 400:
31-
reject(new Exceptions.Malformed(`${firstErr.message}: ${firstErr.field}` || "Not Found"));
31+
const message = firstErr.code === "invalid_field" ? `${firstErr.message}: ${firstErr.field}` : firstErr.message;
32+
reject(new Exceptions.Malformed(message || "Not Found"));
3233

3334
return;
3435
case 401:

0 commit comments

Comments
 (0)