From d072d876237df00b7ffcd6a39e3684378124236f Mon Sep 17 00:00:00 2001 From: Daniel Devine Date: Thu, 26 Aug 2021 00:00:54 +0000 Subject: [PATCH] Attempt to require 'json' because 'cjson' is not readily available on some platforms. --- raven/init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/raven/init.lua b/raven/init.lua index 452f4f3..2de5dcb 100644 --- a/raven/init.lua +++ b/raven/init.lua @@ -8,7 +8,10 @@ -- @license BSD 3-clause (see LICENSE file) local util = require 'raven.util' -local cjson = require 'cjson' + +-- If cjson not avilable, attempt to use 'json' instead. +local _, cjson = pcall(require, 'cjson') +local _, jsonlib = pcall(require, 'json') local _M = {} _M._VERSION = util._VERSION @@ -18,7 +21,7 @@ local table_insert = table.insert local unpack = unpack or table.unpack -- luacheck: ignore local generate_event_id = util.generate_event_id local iso8601 = util.iso8601 -local json_encode = cjson.encode +local json_encode = cjson.encode or jsonlib.encode local catcher_trace_level = 4