Skip to content

Commit 8f8f0ef

Browse files
committed
fix: Remove error codes from external error messaging as these codes are not documented anywhere and subject to change
1 parent d9e14fb commit 8f8f0ef

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

c-dependencies/js-compute-runtime/host_call.h

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,88 +19,87 @@ static inline void handle_fastly_error(JSContext *cx, fastly_error_t err, int li
1919
case FASTLY_ERROR_GENERIC_ERROR:
2020
JS_ReportErrorUTF8(cx,
2121
"%s: Generic error value. This means that some unexpected error "
22-
"occurred during a hostcall. - Fastly error code %d\n",
23-
func, err);
22+
"occurred during a hostcall.\n",
23+
func);
2424

2525
break;
2626
case FASTLY_ERROR_INVALID_ARGUMENT:
27-
JS_ReportErrorUTF8(cx, "%s: Invalid argument. - Fastly error code %d\n", func, err);
27+
JS_ReportErrorUTF8(cx, "%s: Invalid argument.\n", func);
2828
break;
2929
case FASTLY_ERROR_BAD_HANDLE:
3030
JS_ReportErrorUTF8(cx,
3131
"%s: Invalid handle. Thrown when a request, response, dictionary, or "
32-
"body handle is not valid. - Fastly error code %d\n",
33-
func, err);
32+
"body handle is not valid.\n",
33+
func);
3434
break;
3535
case FASTLY_ERROR_BUFFER_LEN:
36-
JS_ReportErrorUTF8(cx, "%s: Buffer length error. Buffer is too long. - Fastly error code %d\n",
37-
func, err);
36+
JS_ReportErrorUTF8(cx, "%s: Buffer length error. Buffer is too long.\n", func);
3837
break;
3938
case FASTLY_ERROR_UNSUPPORTED:
4039
JS_ReportErrorUTF8(cx,
4140
"%s: Unsupported operation error. This error is thrown "
4241
"when some operation cannot be performed, because it is "
43-
"not supported. - Fastly error code %d\n",
44-
func, err);
42+
"not supported.\n",
43+
func);
4544
break;
4645
case FASTLY_ERROR_BAD_ALIGN:
4746
JS_ReportErrorUTF8(cx,
4847
"%s: Alignment error. This is thrown when a pointer does not point to "
49-
"a properly aligned slice of memory. - Fastly error code %d\n",
50-
func, err);
48+
"a properly aligned slice of memory.\n",
49+
func);
5150
break;
5251
case FASTLY_ERROR_HTTP_INVALID:
5352
JS_ReportErrorUTF8(cx,
5453
"%s: HTTP parse error. This can be thrown when a method, URI, header, "
5554
"or status is not valid. This can also be thrown if a message head is "
56-
"too large. - Fastly error code %d\n",
57-
func, err);
55+
"too large.\n",
56+
func);
5857
break;
5958
case FASTLY_ERROR_HTTP_USER:
6059
JS_ReportErrorUTF8(cx,
6160
"%s: HTTP user error. This is thrown in cases where user code caused "
6261
"an HTTP error. For example, attempt to send a 1xx response code, or a "
6362
"request with a non-absolute URI. This can also be caused by an "
6463
"unexpected header: both `content-length` and `transfer-encoding`, for "
65-
"example. - Fastly error code %d\n",
66-
func, err);
64+
"example.\n",
65+
func);
6766
break;
6867
case FASTLY_ERROR_HTTP_INCOMPLETE:
6968
JS_ReportErrorUTF8(cx,
7069
"%s: HTTP incomplete message error. A stream ended "
71-
"unexpectedly. - Fastly error code %d\n",
72-
func, err);
70+
"unexpectedly.\n",
71+
func);
7372
break;
7473
case FASTLY_ERROR_OPTIONAL_NONE:
7574
JS_ReportErrorUTF8(cx,
7675
"%s: A `None` error. This status code is used to "
7776
"indicate when an optional value did not exist, as "
78-
"opposed to an empty value. - Fastly error code %d\n",
79-
func, err);
77+
"opposed to an empty value.\n",
78+
func);
8079
break;
8180
case FASTLY_ERROR_HTTP_HEAD_TOO_LARGE:
8281
JS_ReportErrorUTF8(cx,
8382
"%s: HTTP head too large error. This error will be thrown when the "
84-
"message head is too large. - Fastly error code %d\n",
85-
func, err);
83+
"message head is too large.\n",
84+
func);
8685
break;
8786
case FASTLY_ERROR_HTTP_INVALID_STATUS:
8887
JS_ReportErrorUTF8(cx,
8988
"%s: HTTP invalid status error. This error will be "
9089
"thrown when the HTTP message contains an invalid "
91-
"status code. - Fastly error code %d\n",
92-
func, err);
90+
"status code.\n",
91+
func);
9392
break;
9493
case FASTLY_ERROR_LIMIT_EXCEEDED:
9594
JS_ReportErrorUTF8(cx,
9695
"%s: Limit exceeded error. This error will be thrown when an attempt"
9796
"to allocate a resource has exceeded the maximum number of resources"
9897
"permitted. For example, creating too many response handles."
99-
" - Fastly error code %d\n",
100-
func, err);
98+
"\n",
99+
func);
101100
break;
102101
default:
103-
fprintf(stdout, __FILE__ ":%d (%s) - Fastly error code %d\n", line, func, err);
102+
fprintf(stdout, __FILE__ ":%d (%s)\n", line, func);
104103
JS_ReportErrorUTF8(cx, "Fastly error code %d", err);
105104
}
106105
}

0 commit comments

Comments
 (0)