@opvious/stl-errors
Advanced tools
| export declare function format(fmt: string, ...args: any[]): string; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.format = void 0; | ||
| function format(fmt, ...args) { | ||
| const formatPattern = /(%?)(%([jds]))/g; | ||
| if (args.length) { | ||
| fmt = fmt.replace(formatPattern, (match, esc, _ptn, flag) => { | ||
| let arg = args.shift(); | ||
| switch (flag) { | ||
| case 's': | ||
| arg = '' + arg; | ||
| break; | ||
| case 'd': | ||
| arg = Number(arg); | ||
| break; | ||
| case 'j': | ||
| arg = JSON.stringify(arg); | ||
| break; | ||
| } | ||
| if (!esc) { | ||
| return arg; | ||
| } | ||
| args.unshift(arg); | ||
| return match; | ||
| }); | ||
| } | ||
| if (args.length) { | ||
| fmt += ' ' + args.join(' '); | ||
| } | ||
| fmt = fmt.replace(/%{2,2}/g, '%'); | ||
| return '' + fmt; | ||
| } | ||
| exports.format = format; |
+3
-6
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.unimplemented = exports.fail = exports.validate = exports.findFailure = exports.findStatus = exports.check = exports.newChecker = exports.assertType = exports.assertCause = exports.assert = exports.statusToHttpCode = exports.statusToGrpcCode = exports.statusFromHttpCode = exports.statusFromGrpcCode = exports.statusErrors = exports.statusError = exports.isStatusError = exports.isServerProblem = exports.isErrorStatus = exports.newError = exports.mergeErrorCodes = exports.isStandardError = exports.errors = exports.errorMessage = exports.errorFactories = exports.errorCodes = exports.errorCode = exports.statusErrorCauseExtractor = exports.setCauseExtractors = exports.rethrowWithStatus = exports.findErrorWithCode = exports.findError = exports.errorCauseExtractor = exports.collectErrorCodes = void 0; | ||
| const format_util_1 = __importDefault(require("format-util")); | ||
| const cause_1 = require("./cause"); | ||
| const common_1 = require("./common"); | ||
| const factories_1 = require("./factories"); | ||
@@ -45,3 +42,3 @@ const status_1 = require("./status"); | ||
| throw factories_1.errors.illegal({ | ||
| message: 'Assertion failed: ' + (0, format_util_1.default)(fmt, ...args), | ||
| message: 'Assertion failed: ' + (0, common_1.format)(fmt, ...args), | ||
| stackFrom: assert, | ||
@@ -147,3 +144,3 @@ }); | ||
| ...opts, | ||
| message: fmt == null ? undefined : (0, format_util_1.default)(fmt, ...args), | ||
| message: fmt == null ? undefined : (0, common_1.format)(fmt, ...args), | ||
| stackFrom: validate, | ||
@@ -150,0 +147,0 @@ }); |
+12
-6
| { | ||
| "name": "@opvious/stl-errors", | ||
| "version": "0.14.1", | ||
| "version": "0.14.2", | ||
| "repository": "github:opvious/stl.ts", | ||
| "description": "Standard errors library", | ||
| "description": "Standard errors", | ||
| "keywords": [ | ||
@@ -11,15 +11,21 @@ "stl" | ||
| "license": "Apache-2.0", | ||
| "main": "lib/", | ||
| "sideEffects": false, | ||
| "files": [ | ||
| "lib/" | ||
| ], | ||
| "exports": { | ||
| ".": "./lib/index.js" | ||
| }, | ||
| "typesVersions": { | ||
| "*": { | ||
| "*": [ | ||
| "./lib/*" | ||
| ] | ||
| } | ||
| }, | ||
| "dependencies": { | ||
| "@opentelemetry/api": "^1.2.0", | ||
| "change-case": "^4.1.2", | ||
| "format-util": "^1.0.5", | ||
| "upper-case-first": "^2.0.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/format-util": "^1.0.2", | ||
| "@types/jest": "^27.0.3", | ||
@@ -26,0 +32,0 @@ "@types/node": "^18.8.5", |
62720
1.34%3
-25%7
-12.5%15
15.38%1221
2.61%- Removed
- Removed