1111#include " fastly.h"
1212#include " js/Conversions.h"
1313#include " js/JSON.h"
14+ #include " kv-store.h"
1415#include " logger.h"
1516#include < arpa/inet.h>
1617
@@ -38,14 +39,6 @@ bool debug_logging_enabled() { return DEBUG_LOGGING_ENABLED; }
3839
3940namespace fastly ::fastly {
4041
41- const JSErrorFormatString *FastlyGetErrorMessage (void *userRef, unsigned errorNumber) {
42- if (errorNumber > 0 && errorNumber < JSErrNum_Limit) {
43- return &fastly_ErrorFormatString[errorNumber];
44- }
45-
46- return nullptr ;
47- }
48-
4942JS::PersistentRooted<JSObject *> Fastly::env;
5043JS::PersistentRooted<JSObject *> Fastly::baseURL;
5144JS::PersistentRooted<JSString *> Fastly::defaultBackend;
@@ -57,6 +50,26 @@ bool Fastly::dump(JSContext *cx, unsigned argc, JS::Value *vp) {
5750 if (!args.requireAtLeast (cx, __func__, 1 ))
5851 return false ;
5952
53+ // special debug mode operations
54+ #ifndef NDEBUG
55+ if (args.get (0 ).isNull () && args.get (1 ).isString ()) {
56+ JS::RootedString str (cx, args.get (1 ).toString ());
57+ auto str_chars = core::encode (cx, str);
58+ if (!str_chars) {
59+ return false ;
60+ }
61+ if (!strcmp (str_chars.ptr .get (), " invalidkv" )) {
62+ host_api::HttpBody body (-1 );
63+ host_api::HostBytes metadata{};
64+ // uint32_t gen = std::get<2>(res.unwrap());
65+ JS::RootedObject entry (
66+ cx, ::fastly::kv_store::KVStoreEntry::create (cx, body, std::move (metadata)));
67+ args.rval ().setObject (*entry);
68+ return true ;
69+ }
70+ }
71+ #endif
72+
6073 ENGINE->dump_value (args[0 ], stdout);
6174
6275 args.rval ().setUndefined ();
0 commit comments