@openmrs/esm-error-handling 3.1.10-pre.90 → 3.1.11-pre.595
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/__mocks__/openmrs-esm-globals.mock.tsx +1 -0
- package/dist/openmrs-esm-error-handling.js +1 -1
- package/dist/openmrs-esm-error-handling.js.map +1 -1
- package/docs/API.md +83 -0
- package/jest.config.js +9 -0
- package/package.json +5 -7
- package/src/index.ts +10 -6
- package/typedoc.json +7 -0
- package/webpack.config.js +5 -12
- package/__mocks__/openmrs-esm-styleguide.mock.tsx +0 -5
- package/__mocks__/set-public-path.tsx +0 -1
- package/jest.config.json +0 -5
- package/src/set-public-path.ts +0 -3
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Doesn't have to actually do anything
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["@openmrs/esm-
|
|
1
|
+
System.register(["@openmrs/esm-globals"],(function(r,t){var e={};return{setters:[function(r){e.dispatchNotificationShown=r.dispatchNotificationShown}],execute:function(){r((()=>{var r={968:(r,t,e)=>{const o=e(577).R;t.s=function(r){if(r||(r=1),!e.y.meta||!e.y.meta.url)throw console.error("__system_context__",e.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");e.p=o(e.y.meta.url,r)}},577:(r,t,e)=>{t.R=function(r,t){var e=document.createElement("a");e.href=r;for(var o="/"===e.pathname[0]?e.pathname:"/"+e.pathname,n=0,i=o.length;n!==t&&i>=0;)"/"===o[--i]&&n++;if(n!==t)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+t+") is greater than the number of directories ("+n+") in the URL path "+r);var c=o.slice(0,i+1);return e.protocol+"//"+e.host+c};Number.isInteger},728:r=>{"use strict";r.exports=e}},o={};function n(t){var e=o[t];if(void 0!==e)return e.exports;var i=o[t]={exports:{}};return r[t](i,i.exports,n),i.exports}n.y=t,n.d=(r,t)=>{for(var e in t)n.o(t,e)&&!n.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(r){if("object"==typeof window)return window}}(),n.o=(r,t)=>Object.prototype.hasOwnProperty.call(r,t),n.r=r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},(()=>{var r;n.g.importScripts&&(r=n.g.location+"");var t=n.g.document;if(!r&&t&&(t.currentScript&&(r=t.currentScript.src),!r)){var e=t.getElementsByTagName("script");e.length&&(r=e[e.length-1].src)}if(!r)throw new Error("Automatic publicPath is not supported in this browser");r=r.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=r})();var i={};return(0,n(968).s)(1),(()=>{"use strict";n.r(i),n.d(i,{handleApiError:()=>t,reportError:()=>e,createErrorHandler:()=>o});var r=n(728);function t(){return r=>{setTimeout((()=>{throw r}))}}function e(r){const t=c(r);setTimeout((()=>{throw t}))}function o(){const r=Error();return t=>{c(t).stack+=`\nAsync stacktrace:\n${r.stack}`,e(t)}}function c(r){let t;if(r instanceof Error)return r;if(null===r)return Error("'null' was thrown as an error");if("object"==typeof r){try{t=`Object thrown as error: ${JSON.stringify(r)}`}catch(e){t=`Object thrown as error with the following properties: ${Object.keys(r)}`}return Error(t)}return void 0===r?Error("'undefined' was thrown as an error"):Error(r.toString())}window.onerror=function(){return(0,r.dispatchNotificationShown)({description:"Oops! An unexpected error occurred."}),!1},window.onunhandledrejection=function(){(0,r.dispatchNotificationShown)({description:"Oops! An unexpected error occurred."})}})(),i})())}}}));
|
|
2
2
|
//# sourceMappingURL=openmrs-esm-error-handling.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@openmrs/esm-styleguide\"","webpack:////home/runner/work/openmrs-esm-core/openmrs-esm-core/node_modules/systemjs-webpack-interop/public-path.js","webpack:///./src/set-public-path.ts","webpack:///./src/index.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","__WEBPACK_EXTERNAL_MODULE__0__","resolveDirectory","urlString","rootDirectoryLevel","a","document","createElement","href","pathname","numDirsProcessed","index","length","Error","finalPath","slice","protocol","host","setPublicPath","systemjsModuleName","trim","isInteger","moduleUrl","window","System","resolve","err","Number","val","isFinite","Math","floor","handleApiError","incomingResponseErr","setTimeout","reportError","error","ensureErrorObject","createErrorHandler","outgoingErr","incomingErr","stack","thing","message","JSON","stringify","e","keys","undefined","toString","onerror","showToast","description","onunhandledrejection","event"],"mappings":"kIACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EA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KA,GAHKA,IACHA,EAAqB,GAGS,iBAAvBe,GAC8B,IAArCA,EAAmBC,OAAOR,OAE1B,MAAMC,MACJ,2HAIJ,GACgC,iBAAvBT,GACPA,GAAsB,IACrBiB,EAAUjB,GAEX,MAAMS,MACJ,+IAIJ,IAAIS,EACJ,IAEE,GADAA,EAAYC,OAAOC,OAAOC,QAAQN,IAC7BG,EACH,MAAMT,QAER,MAAOa,GACP,MAAMb,MACJ,sDACEM,EACA,yEAIN,IAA0BjB,EAAiBoB,EAAWlB,IAqCxDrC,EAAQmC,iBAAmBA,EAG3B,MAAMmB,EACJM,OAAON,WACP,SAAmBO,GACjB,MAAsB,iBAARA,GAAoBC,SAASD,IAAQE,KAAKC,MAAMH,KAASA,I,kECnF3E,kBAEAV,wBAAc,gC,6BCFd,gKAEO,SAASc,IACd,OAAQC,IACNC,WAAW,KACT,MAAMD,KAeL,SAASE,EAAYT,GAC1B,MAAMU,EAAQC,EAAkBX,GAChCQ,WAAW,KACT,MAAME,IAIH,SAASE,IACd,MAAMC,EAAc1B,QACpB,OAAQ2B,IACWH,EAAkBG,GAC1BC,OAAU,wBAAuBF,EAAYE,MACtDN,EAAYK,IAIhB,SAASH,EAAkBK,GACzB,IAAIC,EACJ,GAAID,aAAiB7B,MACnB,OAAO6B,EACF,GAAc,OAAVA,EACT,OAAO7B,MAAO,iCACT,GAAqB,iBAAV6B,EAAoB,CACpC,IACEC,EAAW,2BAA0BC,KAAKC,UAAUH,GACpD,MAAOI,GACPH,EAAW,yDAAwDhE,OAAOoE,KACxEL,GAGJ,OAAO7B,MAAM8B,GACR,YAAcK,IAAVN,EACF7B,MAAO,sCAEPA,MAAM6B,EAAMO,YA5CvB1B,OAAO2B,QAAU,WAGf,OAFAC,oBAAU,CAAEC,YAAa,yCAElB,GAGT7B,OAAO8B,qBAAuB,SAAUC,GACtCH,oBAAU,CAAEC,YAAc","file":"openmrs-esm-error-handling.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","exports.setPublicPath = function setPublicPath(\n systemjsModuleName,\n rootDirectoryLevel\n) {\n if (!rootDirectoryLevel) {\n rootDirectoryLevel = 1;\n }\n if (\n typeof systemjsModuleName !== \"string\" ||\n systemjsModuleName.trim().length === 0\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'\"\n );\n }\n\n if (\n typeof rootDirectoryLevel !== \"number\" ||\n rootDirectoryLevel <= 0 ||\n !isInteger(rootDirectoryLevel)\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'\"\n );\n }\n\n let moduleUrl;\n try {\n moduleUrl = window.System.resolve(systemjsModuleName);\n if (!moduleUrl) {\n throw Error();\n }\n } catch (err) {\n throw Error(\n \"systemjs-webpack-interop: There is no such module '\" +\n systemjsModuleName +\n \"' in the SystemJS registry. Did you misspell the name of your module?\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(moduleUrl, rootDirectoryLevel);\n};\n\nfunction resolveDirectory(urlString, rootDirectoryLevel) {\n // Our friend IE11 doesn't support new URL()\n // https://github.com/single-spa/single-spa/issues/612\n // https://gist.github.com/jlong/2428561\n\n const a = document.createElement(\"a\");\n a.href = urlString;\n\n const pathname = a.pathname[0] === \"/\" ? a.pathname : \"/\" + a.pathname;\n let numDirsProcessed = 0,\n index = pathname.length;\n while (numDirsProcessed !== rootDirectoryLevel && index >= 0) {\n const char = pathname[--index];\n if (char === \"/\") {\n numDirsProcessed++;\n }\n }\n\n if (numDirsProcessed !== rootDirectoryLevel) {\n throw Error(\n \"systemjs-webpack-interop: rootDirectoryLevel (\" +\n rootDirectoryLevel +\n \") is greater than the number of directories (\" +\n numDirsProcessed +\n \") in the URL path \" +\n urlString\n );\n }\n\n const finalPath = pathname.slice(0, index + 1);\n\n return a.protocol + \"//\" + a.host + finalPath;\n}\n\nexports.resolveDirectory = resolveDirectory;\n\n// borrowed from https://github.com/parshap/js-is-integer/blob/master/index.js\nconst isInteger =\n Number.isInteger ||\n function isInteger(val) {\n return typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n };\n","import { setPublicPath } from \"systemjs-webpack-interop\";\n\nsetPublicPath(\"@openmrs/esm-error-handling\");\n","import { showToast } from \"@openmrs/esm-styleguide\";\n\nexport function handleApiError() {\n return (incomingResponseErr) => {\n setTimeout(() => {\n throw incomingResponseErr;\n });\n };\n}\n\nwindow.onerror = function () {\n showToast({ description: \"Oops! An unexpected error occurred.\" });\n\n return false;\n};\n\nwindow.onunhandledrejection = function (event) {\n showToast({ description: `Oops! An unexpected error occurred.` });\n};\n\nexport function reportError(err) {\n const error = ensureErrorObject(err);\n setTimeout(() => {\n throw error;\n });\n}\n\nexport function createErrorHandler() {\n const outgoingErr = Error();\n return (incomingErr) => {\n const finalErr = ensureErrorObject(incomingErr);\n finalErr.stack += `\\nAsync stacktrace:\\n${outgoingErr.stack}`;\n reportError(incomingErr);\n };\n}\n\nfunction ensureErrorObject(thing) {\n let message;\n if (thing instanceof Error) {\n return thing;\n } else if (thing === null) {\n return Error(`'null' was thrown as an error`);\n } else if (typeof thing === \"object\") {\n try {\n message = `Object thrown as error: ${JSON.stringify(thing)}`;\n } catch (e) {\n message = `Object thrown as error with the following properties: ${Object.keys(\n thing\n )}`;\n }\n return Error(message);\n } else if (thing === undefined) {\n return Error(`'undefined' was thrown as an error`);\n } else {\n return Error(thing.toString());\n }\n}\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"openmrs-esm-error-handling.js","mappings":"uMAAA,MAAMA,EAAmB,SAEzBC,EAAQ,EAAiB,SAAwBC,GAY7C,GAXGA,IACHA,EAAe,IAUV,IAAmBC,OAAS,IAAmBA,KAAKC,IAEvD,MADAC,QAAQC,MAAM,qBAAsB,KAC9BC,MACJ,uHAIJ,IAA0BP,EACxB,IAAmBG,KAAKC,IACxBF,K,cCuDND,EAAQ,EAlCR,SAA0BO,EAAWC,GAKnC,IAAIC,EAAIC,SAASC,cAAc,KAC/BF,EAAEG,KAAOL,EAKT,IAHA,IAAIM,EAA6B,MAAlBJ,EAAEI,SAAS,GAAaJ,EAAEI,SAAW,IAAMJ,EAAEI,SACxDC,EAAmB,EACrBC,EAAQF,EAASG,OACZF,IAAqBN,GAAsBO,GAAS,GAE5C,MADFF,IAAWE,IAEpBD,IAIJ,GAAIA,IAAqBN,EACvB,MAAMF,MACJ,iDACEE,EACA,gDACAM,EACA,qBACAP,GAIN,IAAIU,EAAYJ,EAASK,MAAM,EAAGH,EAAQ,GAE1C,OAAON,EAAEU,SAAW,KAAOV,EAAEW,KAAOH,GAOpCI,OAAOC,W,qBClFTC,EAAOvB,QAAUwB,ICCbC,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa5B,QAGrB,IAAIuB,EAASE,EAAyBE,GAAY,CAGjD3B,QAAS,IAOV,OAHA8B,EAAoBH,GAAUJ,EAAQA,EAAOvB,QAAS0B,GAG/CH,EAAOvB,QCrBf0B,EAAoBK,EAAIC,ECCxBN,EAAoBO,EAAI,CAACjC,EAASkC,KACjC,IAAI,IAAIC,KAAOD,EACXR,EAAoBU,EAAEF,EAAYC,KAAST,EAAoBU,EAAEpC,EAASmC,IAC5EE,OAAOC,eAAetC,EAASmC,EAAK,CAAEI,Y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A,EACT,OAAOtE,MAAO,iCACT,GAAqB,iBAAVsE,EAAoB,CACpC,IACEC,EAAW,2BAA0BC,KAAKC,UAAUH,KACpD,MAAO/B,GACPgC,EAAW,yDAAwDxC,OAAO2C,KACxEJ,KAGJ,OAAOtE,MAAMuE,GACR,YAAchD,IAAV+C,EACFtE,MAAO,sCAEPA,MAAMsE,EAAMK,YAhDvBnC,OAAOoC,QAAU,WAIf,OAHAC,EAAAA,EAAAA,2BAA0B,CACxBC,YAAa,yCAER,GAGTtC,OAAOuC,qBAAuB,YAC5BF,EAAAA,EAAAA,2BAA0B,CACxBC,YAAa,0C","sources":["webpack://@openmrs/esm-error-handling/../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js","webpack://@openmrs/esm-error-handling/../../../node_modules/systemjs-webpack-interop/public-path.js","webpack://@openmrs/esm-error-handling/external system \"@openmrs/esm-globals\"","webpack://@openmrs/esm-error-handling/webpack/bootstrap","webpack://@openmrs/esm-error-handling/webpack/runtime/__system_context__","webpack://@openmrs/esm-error-handling/webpack/runtime/define property getters","webpack://@openmrs/esm-error-handling/webpack/runtime/global","webpack://@openmrs/esm-error-handling/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-error-handling/webpack/runtime/make namespace object","webpack://@openmrs/esm-error-handling/webpack/runtime/publicPath","webpack://@openmrs/esm-error-handling/../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js","webpack://@openmrs/esm-error-handling/./src/index.ts"],"sourcesContent":["const resolveDirectory = require(\"../public-path\").resolveDirectory;\n\nexports.autoPublicPath = function autoPublicPath(rootDirLevel) {\n if (!rootDirLevel) {\n rootDirLevel = 1;\n }\n\n if (typeof __webpack_public_path__ !== \"undefined\") {\n if (typeof __system_context__ === \"undefined\") {\n throw Error(\n \"systemjs-webpack-interop requires webpack@>=5.0.0-beta.15 and output.libraryTarget set to 'system'\"\n );\n }\n\n if (!__system_context__.meta || !__system_context__.meta.url) {\n console.error(\"__system_context__\", __system_context__);\n throw Error(\n \"systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(\n __system_context__.meta.url,\n rootDirLevel\n );\n }\n};\n","exports.setPublicPath = function setPublicPath(\n systemjsModuleName,\n rootDirectoryLevel\n) {\n if (!rootDirectoryLevel) {\n rootDirectoryLevel = 1;\n }\n if (\n typeof systemjsModuleName !== \"string\" ||\n systemjsModuleName.trim().length === 0\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'\"\n );\n }\n\n if (\n typeof rootDirectoryLevel !== \"number\" ||\n rootDirectoryLevel <= 0 ||\n isNaN(rootDirectoryLevel) ||\n !isInteger(rootDirectoryLevel)\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'\"\n );\n }\n\n var moduleUrl;\n try {\n moduleUrl = window.System.resolve(systemjsModuleName);\n if (!moduleUrl) {\n throw Error();\n }\n } catch (err) {\n throw Error(\n \"systemjs-webpack-interop: There is no such module '\" +\n systemjsModuleName +\n \"' in the SystemJS registry. Did you misspell the name of your module?\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(moduleUrl, rootDirectoryLevel);\n};\n\nfunction resolveDirectory(urlString, rootDirectoryLevel) {\n // Our friend IE11 doesn't support new URL()\n // https://github.com/single-spa/single-spa/issues/612\n // https://gist.github.com/jlong/2428561\n\n var a = document.createElement(\"a\");\n a.href = urlString;\n\n var pathname = a.pathname[0] === \"/\" ? a.pathname : \"/\" + a.pathname;\n var numDirsProcessed = 0,\n index = pathname.length;\n while (numDirsProcessed !== rootDirectoryLevel && index >= 0) {\n var char = pathname[--index];\n if (char === \"/\") {\n numDirsProcessed++;\n }\n }\n\n if (numDirsProcessed !== rootDirectoryLevel) {\n throw Error(\n \"systemjs-webpack-interop: rootDirectoryLevel (\" +\n rootDirectoryLevel +\n \") is greater than the number of directories (\" +\n numDirsProcessed +\n \") in the URL path \" +\n urlString\n );\n }\n\n var finalPath = pathname.slice(0, index + 1);\n\n return a.protocol + \"//\" + a.host + finalPath;\n}\n\nexports.resolveDirectory = resolveDirectory;\n\n// borrowed from https://github.com/parshap/js-is-integer/blob/master/index.js\nvar isInteger =\n Number.isInteger ||\n function isInteger(val) {\n return typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n };\n","module.exports = __WEBPACK_EXTERNAL_MODULE__728__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.y = __system_context__;","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) scriptUrl = scripts[scripts.length - 1].src\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","const autoPublicPath = require(\"./auto-public-path\").autoPublicPath;\n\nautoPublicPath(1);\n","import { dispatchNotificationShown } from \"@openmrs/esm-globals\";\n\nexport function handleApiError() {\n return (incomingResponseErr) => {\n setTimeout(() => {\n throw incomingResponseErr;\n });\n };\n}\n\nwindow.onerror = function () {\n dispatchNotificationShown({\n description: \"Oops! An unexpected error occurred.\",\n });\n return false;\n};\n\nwindow.onunhandledrejection = function () {\n dispatchNotificationShown({\n description: \"Oops! An unexpected error occurred.\",\n });\n};\n\nexport function reportError(err) {\n const error = ensureErrorObject(err);\n setTimeout(() => {\n throw error;\n });\n}\n\nexport function createErrorHandler() {\n const outgoingErr = Error();\n return (incomingErr) => {\n const finalErr = ensureErrorObject(incomingErr);\n finalErr.stack += `\\nAsync stacktrace:\\n${outgoingErr.stack}`;\n reportError(incomingErr);\n };\n}\n\nfunction ensureErrorObject(thing: any) {\n let message;\n\n if (thing instanceof Error) {\n return thing;\n } else if (thing === null) {\n return Error(`'null' was thrown as an error`);\n } else if (typeof thing === \"object\") {\n try {\n message = `Object thrown as error: ${JSON.stringify(thing)}`;\n } catch (e) {\n message = `Object thrown as error with the following properties: ${Object.keys(\n thing\n )}`;\n }\n return Error(message);\n } else if (thing === undefined) {\n return Error(`'undefined' was thrown as an error`);\n } else {\n return Error(thing.toString());\n }\n}\n"],"names":["resolveDirectory","exports","rootDirLevel","meta","url","console","error","Error","urlString","rootDirectoryLevel","a","document","createElement","href","pathname","numDirsProcessed","index","length","finalPath","slice","protocol","host","Number","isInteger","module","__WEBPACK_EXTERNAL_MODULE__728__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","y","__system_context__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","this","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","scriptUrl","importScripts","location","currentScript","src","scripts","getElementsByTagName","replace","p","autoPublicPath","handleApiError","incomingResponseErr","setTimeout","reportError","err","ensureErrorObject","createErrorHandler","outgoingErr","incomingErr","stack","thing","message","JSON","stringify","keys","toString","onerror","dispatchNotificationShown","description","onunhandledrejection"],"sourceRoot":""}
|
package/docs/API.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
[Back to README.md](../README.md)
|
|
2
|
+
|
|
3
|
+
# @openmrs/esm-error-handling
|
|
4
|
+
|
|
5
|
+
## Table of contents
|
|
6
|
+
|
|
7
|
+
### Functions
|
|
8
|
+
|
|
9
|
+
- [createErrorHandler](API.md#createerrorhandler)
|
|
10
|
+
- [handleApiError](API.md#handleapierror)
|
|
11
|
+
- [reportError](API.md#reporterror)
|
|
12
|
+
|
|
13
|
+
## Functions
|
|
14
|
+
|
|
15
|
+
### createErrorHandler
|
|
16
|
+
|
|
17
|
+
▸ **createErrorHandler**(): (`incomingErr`: `any`) => `void`
|
|
18
|
+
|
|
19
|
+
#### Returns
|
|
20
|
+
|
|
21
|
+
`fn`
|
|
22
|
+
|
|
23
|
+
▸ (`incomingErr`): `void`
|
|
24
|
+
|
|
25
|
+
##### Parameters
|
|
26
|
+
|
|
27
|
+
| Name | Type |
|
|
28
|
+
| :------ | :------ |
|
|
29
|
+
| `incomingErr` | `any` |
|
|
30
|
+
|
|
31
|
+
##### Returns
|
|
32
|
+
|
|
33
|
+
`void`
|
|
34
|
+
|
|
35
|
+
#### Defined in
|
|
36
|
+
|
|
37
|
+
[index.ts:31](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-error-handling/src/index.ts#L31)
|
|
38
|
+
|
|
39
|
+
___
|
|
40
|
+
|
|
41
|
+
### handleApiError
|
|
42
|
+
|
|
43
|
+
▸ **handleApiError**(): (`incomingResponseErr`: `any`) => `void`
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`fn`
|
|
48
|
+
|
|
49
|
+
▸ (`incomingResponseErr`): `void`
|
|
50
|
+
|
|
51
|
+
##### Parameters
|
|
52
|
+
|
|
53
|
+
| Name | Type |
|
|
54
|
+
| :------ | :------ |
|
|
55
|
+
| `incomingResponseErr` | `any` |
|
|
56
|
+
|
|
57
|
+
##### Returns
|
|
58
|
+
|
|
59
|
+
`void`
|
|
60
|
+
|
|
61
|
+
#### Defined in
|
|
62
|
+
|
|
63
|
+
[index.ts:3](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-error-handling/src/index.ts#L3)
|
|
64
|
+
|
|
65
|
+
___
|
|
66
|
+
|
|
67
|
+
### reportError
|
|
68
|
+
|
|
69
|
+
▸ **reportError**(`err`): `void`
|
|
70
|
+
|
|
71
|
+
#### Parameters
|
|
72
|
+
|
|
73
|
+
| Name | Type |
|
|
74
|
+
| :------ | :------ |
|
|
75
|
+
| `err` | `any` |
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
`void`
|
|
80
|
+
|
|
81
|
+
#### Defined in
|
|
82
|
+
|
|
83
|
+
[index.ts:24](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-error-handling/src/index.ts#L24)
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-error-handling",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.11-pre.595",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "An ES module to help with error handling",
|
|
6
6
|
"browser": "dist/openmrs-esm-error-handling.js",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
8
|
"source": true,
|
|
9
9
|
"scripts": {
|
|
10
|
+
"document": "../../../document.sh esm-error-handling",
|
|
10
11
|
"test": "jest --passWithNoTests",
|
|
11
12
|
"build": "webpack --mode=production",
|
|
12
13
|
"analyze": "webpack --mode=production --env.analyze=true",
|
|
@@ -35,14 +36,11 @@
|
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|
|
37
38
|
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"systemjs-webpack-interop": "^2.1.2"
|
|
40
|
-
},
|
|
41
39
|
"peerDependencies": {
|
|
42
|
-
"@openmrs/esm-
|
|
40
|
+
"@openmrs/esm-globals": "3.x"
|
|
43
41
|
},
|
|
44
42
|
"devDependencies": {
|
|
45
|
-
"@openmrs/esm-
|
|
43
|
+
"@openmrs/esm-globals": "^3.1.11-pre.595"
|
|
46
44
|
},
|
|
47
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c2141b8223409e20051338ee5109eb4e40cd19f0"
|
|
48
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dispatchNotificationShown } from "@openmrs/esm-globals";
|
|
2
2
|
|
|
3
3
|
export function handleApiError() {
|
|
4
4
|
return (incomingResponseErr) => {
|
|
@@ -9,13 +9,16 @@ export function handleApiError() {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
window.onerror = function () {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
dispatchNotificationShown({
|
|
13
|
+
description: "Oops! An unexpected error occurred.",
|
|
14
|
+
});
|
|
14
15
|
return false;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
window.onunhandledrejection = function (
|
|
18
|
-
|
|
18
|
+
window.onunhandledrejection = function () {
|
|
19
|
+
dispatchNotificationShown({
|
|
20
|
+
description: "Oops! An unexpected error occurred.",
|
|
21
|
+
});
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
export function reportError(err) {
|
|
@@ -34,8 +37,9 @@ export function createErrorHandler() {
|
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
function ensureErrorObject(thing) {
|
|
40
|
+
function ensureErrorObject(thing: any) {
|
|
38
41
|
let message;
|
|
42
|
+
|
|
39
43
|
if (thing instanceof Error) {
|
|
40
44
|
return thing;
|
|
41
45
|
} else if (thing === null) {
|
package/typedoc.json
ADDED
package/webpack.config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
2
|
+
const SystemJSPublicPathWebpackPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin");
|
|
2
3
|
const { resolve } = require("path");
|
|
3
4
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
4
5
|
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
|
@@ -6,24 +7,15 @@ const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
|
|
6
7
|
const { peerDependencies } = require("./package.json");
|
|
7
8
|
|
|
8
9
|
module.exports = (env) => ({
|
|
9
|
-
entry: [
|
|
10
|
-
resolve(__dirname, "src/set-public-path.ts"),
|
|
11
|
-
resolve(__dirname, "src/index.ts"),
|
|
12
|
-
],
|
|
10
|
+
entry: [resolve(__dirname, "src/index.ts")],
|
|
13
11
|
output: {
|
|
14
12
|
filename: "openmrs-esm-error-handling.js",
|
|
15
13
|
libraryTarget: "system",
|
|
16
14
|
path: resolve(__dirname, "dist"),
|
|
17
|
-
jsonpFunction: "webpackJsonp_openmrs_esm_error_handling",
|
|
18
15
|
},
|
|
19
16
|
mode: "production",
|
|
20
17
|
module: {
|
|
21
18
|
rules: [
|
|
22
|
-
{
|
|
23
|
-
parser: {
|
|
24
|
-
system: false,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
19
|
{
|
|
28
20
|
test: /\.m?(js|ts|tsx)$/,
|
|
29
21
|
exclude: /(node_modules|bower_components)/,
|
|
@@ -33,15 +25,16 @@ module.exports = (env) => ({
|
|
|
33
25
|
},
|
|
34
26
|
],
|
|
35
27
|
},
|
|
36
|
-
devtool: "
|
|
28
|
+
devtool: "source-map",
|
|
37
29
|
devServer: {
|
|
38
30
|
headers: {
|
|
39
31
|
"Access-Control-Allow-Origin": "*",
|
|
40
32
|
},
|
|
41
33
|
disableHostCheck: true,
|
|
42
34
|
},
|
|
43
|
-
externals: Object.keys(peerDependencies),
|
|
35
|
+
externals: Object.keys(peerDependencies || {}),
|
|
44
36
|
plugins: [
|
|
37
|
+
new SystemJSPublicPathWebpackPlugin(),
|
|
45
38
|
new ForkTsCheckerWebpackPlugin(),
|
|
46
39
|
new CleanWebpackPlugin(),
|
|
47
40
|
new BundleAnalyzerPlugin({
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function setPublicPath() {}
|
package/jest.config.json
DELETED
package/src/set-public-path.ts
DELETED