1.0.5 • Published 5 years ago

error-resolver v1.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Error handling self loaded instance of error. It can be used on server side with express.

Install

$ npm install error-resolver

Module is designed for use on backend node for wrapping errors. To use create file error.init.ts. Use this file on top of app.ts.

Usage

Example app.ts

import './error.init'

Example error.init.ts;

import {startErrorResolving} from 'error-resolver'
const ST  = startErrorResolving({errorLevel:'stack'});

Usage

import {checkAgainstUndefined} from 'error-resolver';

let testValue: number | undefined
const checkError = checkAgainstUndefined(testValue)
console.log(checkAnswer); // { hasError:true,errorData:{name:...,message:..., stack:...}}

if(checkAnswer.hasError) return checkError // to roll errors
import {asyncTryFnRun} from 'error-resolver';

//Use this code in async function body
const [maybeValue, maybeError] = await asyncTryFnRun(somePromiseFn, 'arg');
console.log(maybeError);// { hasError:true,errorData:{name:...,message:..., stack:...}}

if(maybeError.hasError) return maybeError // to roll errors as  Promise<IErrorPassingStruct>
const retFromPromiseFn = maybeValue; // if no error
import {tryFnRun } from 'error-resolver';

//Use this code in function body
const [maybeValue, maybeError] = tryFnRun(someFn, 'arg');
console.log(maybeError);// { hasError:true,errorData:{name:...,message:..., stack:...}}

if(maybeError.hasError) return maybeError // to roll errors as IErrorPassingStruct
const retFromFn = maybeValue; // if no error
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago