1.5.11 • Published 1 year ago

@dramaorg/nostrum-officia v1.5.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@dramaorg/nostrum-officia

A little function that formats an error object as a nice, readable string. Works in node and the browser; in node, it will use kleur to add ANSI color code escape sequences to the output string, to make it easier to read.

Features

  • Works in both node and the browser
  • Browser version is only ~2k
  • Error name and stack are printed in color
  • Handles non-error inputs gracefully (accepts unknown in TypeScript)
  • Also prints any additional properties that were added to the Error object
    • This is particularly nice when working with node's fs errors; node sometimes puts the information about eg "which file couldn't be read" is sometimes in a property on the error, rather than in the error message, so by printing additional properties, it's guaranteed to be visible.

Example

Sample output of using @dramaorg/nostrum-officia in the node repl. See the "Usage" section below for the code used in this screenshot.

Installation

npm install @dramaorg/nostrum-officia

Usage

import { formatError } from "@dramaorg/nostrum-officia";

const error = new Error("uh oh!");

error.context = {
  user: "jeff",
  session: "ewnj75hvj3v4tvmuy43er",
  favoriteIceCreamFlavor: "pineapple",
};

console.log(formatError(error));
/*
  Logs:

  Error: uh oh!
    at REPL2:1:9
  The above error also had these properties on it:
  {
    context: {
      user: 'jeff',
      session: 'ewnj75hvj3v4tvmuy43er',
      favoriteIceCreamFlavor: 'pineapple'
    }
  }
*/

License

MIT

inputstringdragconfigurablelintcss-in-jsTypedArraytypees-shimsimmutableimmerObject.assignfeedRxJSbusyisjapanesechaisharedworkspace:*validisConcatSpreadablestructuredCloneObject.entriesBigInt64Arraydeletefpsinferencefixed-widthrobustroutingmetadatarapidtransformconcatMaprestfulebsprototyperfc4122setPrototypeOfmochalengthredacthasrouterdataViewidArraysomesearchcurlsetImmediatezxshrinkwrapaccessibilitylockfileposeUint32ArrayruntimeweakmapflagconcatdifftouchqueryrdscallbackdebugrgbbufferoffsetsnsidentifiersajaxArrayBufferintrinsictelephonejsdiffponyfilllistenersrm -rfexecutewaftypedarraysReactiveXsinatraistanbulform-validationhttparraysescloudtrailpositivetestertypedprefixclasseseffect-tsautoprefixercreateeventEmitterminimalvisualstringifystylesdeepshimglobalsstylingloadbalancingtostringtagiteratoreventDispatcherloggingformspinnersbabel-coreserializationclassnamebeanstalkuser-streamsdeterministicCSSwalkkeyssharedarraybufferES3artframeworkwhatwgregular expressionWebSocketfplruhookformpackage.jsonreadablestreamespreegdprfigletbannerArray.prototype.findLastIndexqsrmAsyncIterator2560spinnerramdamovenameparseansicoerciblepackage managerWeakSetroutemodulecall-boundfindLastIndexES2023rssyamlReflect.getPrototypeOfjavascriptperformantyupvaluestapspawnfnmatchtestingtoArrayavareactutilitySymbol.toStringTagInt32ArrayECMAScript 2019utilscollectionspringprotobufcomputed-typesdependency managerjsdomjoiSymbolECMAScript 2015execfullwidthresolveequalityObject.isEScoloursuperstructruleswritezodclienttypeerrorvalidationnpmemojiwaitupbinariesObject.fromEntriesimportexportttyproxyquotetoolkitgroupschemeInt16ArrayfetchanimationpurecoverageoutputpropendpointjsonschemavalidatemobileHyBiomitphoneregular-expressionsyntaxerrorcopyunicodefunctionsestreeWebSocketsmatchesmruchanneltraversereduxutilRxcryptoES2020System.globalxtermrm -frkarmaio-tsnegative zerodependenciesentrieses2015fsECMAScript 2018typesafeECMAScript 6expressionasyncprotoreducerschemacalles8errorArray.prototype.containseslintdebuggereveryoncebytelocationlook-upes2017agentString.prototype.trimappjson-schema-validatorhelperwebMapkoreancollection.es6dropnodeclireworktoolsboundrmdirreversedsafeargsArray.prototype.findLasthelpersflagsdescriptorargvdynamodbmkdirpqueuetrimlinkmatchAllbrowserlistinstalltranspilereventsglobal objectfile systemgetterconstcircularfast-deep-copyaccessorefficientfantasy-landcolumncallbindnopethreecompilergetOwnPropertyDescriptorES8react posedescriptionObjectworkerhardlinksES2021regular expressionswgetgetPrototypeOfUint8ClampedArraysliceArray.prototype.flattenconfiginternal slotextrafindLastObject.valuesinstallersesjestpropertiescommanderfastcloneinvariantstoragegatewaysubprocesstc39airbnbcharactersTypeScriptdomUint16Arrayfast-cloneprogresshttpscolorsreduceRegExp.prototype.flagsECMAScript 5trimRightclassnamesgetintrinsicnativearktypeletfolderownapiexpresshashchineseStreampipeiamcacheglobal this valueECMAScript 2022valuetime_.extendpushes-abstractSeteslintconfigpackagepropertytsawesomesaucedefinePropertyhas-ownautoscalingchecksyntaxmanagerString.prototype.matchAlltypescriptpopmotiones2018higher-ordercallboundpreprocessorstreamES5startereslint-plugindirectorydataviewMicrosoftlibphonenumbereast-asian-widthqueueMicrotaskkeyformsextendfiltergetarraya11ycontainsJSON-SchemafindupmakeharmonybrowserforEachbddnodejsserializerconsolefunction.lengthCSSStyleDeclarationviewshamselffastutilitiesobject$.extendapolloflatMaptypedarraycensormkdirshellamazones-shim APIECMAScript 2017stylepolyfilli18nxhrtrimStartObservablefull-widthutil.inspectArrayBuffer#sliceprivate datacodeszeroelasticachejson-schemafastifyredirectelbiteratemonoreposimpledbhtmlfilemkdirsexecfilewindowredux-toolkitrestmatchforkurldescriptorswritablebuffersJSONvarcharacterfullsortedArrayBuffer.prototype.sliceglobalfindhasOwnconsumecloudsearchreact-hookschromewarningmergeguidbabelpatch6to5route53jspostcssbyteLengthprocessreact-hook-formes7parent.envenvironmentbyteOffsetinternalECMAScript 2023gitignoreECMAScript 7sideignorenpmignoreStreamsspeedacorndeep-copyECMAScript 2021Float32ArraytakeuuidES2022postcss-pluginUnderscoreArray.prototype.flatMapworkflowdom-testing-libraryformatting__proto__getoptequalescapeindicatorobjStyleSheetlookes2016variablespackagesArray.prototype.filtersource mapnamesindate.gitignoreinstrumentationtrimEndgenericspnpm9URLSearchParamsstreamsajvInt8Arrayoptimistclass-validatorES2015toReversedObject.keysreverseshebangec2kinesiscorefromstyled-componentsidletextgroupBysymbolsecmascriptassertweaksetcjkcolorECMAScript 2016protocol-buffersslotES7jQueryfast-copyYAMLtyped arrayArray.prototype.flatenumerablehooksformatchildWeakMappoint-freebinaryECMAScriptserializestringifierregexes6react animationES2016jasminetoSortedrecursivereusefast-deep-clonePushtransportjshintjsxmapreducepathreadableargumentprunewidthglaciers3sortelectronRegExp#flagsES2019ES6prettyxmlcolumns3dastl10nsetterlocalflattendirglobalThisstyleguidecloudformationasciisymbolpromiseparentssuperagentwhichframerpinooptimizernumbermanipulationObject.definePropertysetbundlertacitasterisksmodulesbinreact-testing-libraryawstoobjectTypeBoxtranspileuninstallURLmake dirswfierangeerrorstablewaapichromiumlogenvscheme-validationtypanionspecendernegativeparserloggerdotenvFloat64ArrayPromisedeep-cloneeslintplugin@@toStringTagincludesES2017requirecurriedterminalObservablesbindimportECMAScript 2020Function.prototype.namesymlinksdefinetslibrequestassertscall-bindbrowserslistECMAScript 3real-timelanguagetermpyyamlperformanceregexpinspectoptionenvironmentssqslastjson-schema-validationdeepclonetddmulti-packagetypeofpicomatchsameValueZeroregularES2018bundlingcode pointscommandgesturesflatreadpluginprivatequerystringremoveassertion[[Prototype]]clonemapfind-upemrassignBigUint64ArrayArray.prototype.includesarraybufferfastcopyIteratorsettings-0command-lineemitatomcomparedataUint8ArrayhasOwnPropertycore-jsgraphqlvpctape
1.5.11

1 year ago

1.5.10

1 year ago

1.5.9

1 year ago

1.5.8

1 year ago

1.5.7

1 year ago

1.5.6

1 year ago

1.5.5

1 year ago

1.5.4

1 year ago

1.4.4

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.2.3

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago