Skip to content

Commit

Permalink
Merge pull request #25 from snyk-tech-services/feat/extra-debug-state…
Browse files Browse the repository at this point in the history
…ments

feat: debug for errors from API
  • Loading branch information
lili2311 authored Oct 8, 2020
2 parents 0f72c3d + 97c6f10 commit 972d9e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/lib/customErrors/requestManagerErrors.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import * as debugModule from 'debug';

import {ApiError,
ApiAuthenticationError,
NotFoundError,
GenericError
} from './apiError'
const debug = debugModule('snyk')

const requestsManagerErrorOverload = (err: Error, channel: string, requestId: string): Error => {
debug('ERROR:', err);
switch(err?.name){
case 'ApiError':
return new RequestsManagerApiError(err.message, channel, requestId)
Expand Down Expand Up @@ -72,4 +76,4 @@ export {
RequestsManagerNotFoundError,
RequestsManagerGenericError,
requestsManagerErrorOverload
}
}
4 changes: 2 additions & 2 deletions src/lib/error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as chalk from 'chalk'
const debugModule = require('debug');
import debugModule = require('debug');


const handleError = (error: Error) => {
Expand Down Expand Up @@ -30,4 +30,4 @@ const handleError = (error: Error) => {
}
}

export default handleError
export default handleError

0 comments on commit 972d9e0

Please sign in to comment.