Skip to content

Commit

Permalink
fix: move custom error types to a better place and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
roperzh committed Nov 14, 2019
1 parent bdd4718 commit 6daed20
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"commander": "^2.19.0",
"enquirer": "^2.3.0",
"fs-extra": "^7.0.1",
"typed-errors": "^1.1.0",
"server-destroy": "^1.0.1"
},
"bin": {
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {makeTypedError} from 'typed-errors';
``
export const UnauthorizedRequestException = makeTypedError('UnauthorizedRequestException');
1 change: 1 addition & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './api';
export * from './utils';
export * from './reporting';
export * from './network';
export * from './errors';
3 changes: 2 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.packages.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
"outDir": "lib",
"baseUrl": "."
},
"include": [
"src/**/*.ts"
Expand Down
1 change: 0 additions & 1 deletion packages/designfile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"pngjs": "^3.3.3",
"request": "^2.88.0",
"server-destroy": "^1.0.1",
"typed-errors": "^1.1.0",
"uuid": "^3.3.2"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/designfile/src/commands/extract.action.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {info, success, warning} from '@diez/cli';
import {info, success, warning, UnauthorizedRequestException} from '@diez/cli';
import {Registry} from '@diez/storage';
import {prompt} from 'enquirer';
import {ExporterFactory} from '../exporters';
import {FigmaExporter, getFigmaAccessToken} from '../exporters/figma';
import {IllustratorExporter} from '../exporters/illustrator';
import {SketchExporter} from '../exporters/sketch';
import {UnauthorizedRequestException} from '../helpers/request';

const findFactory = async (source: string): Promise<ExporterFactory> => {
for (const factory of [FigmaExporter, IllustratorExporter, SketchExporter]) {
Expand Down
4 changes: 1 addition & 3 deletions packages/designfile/src/helpers/request.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {createWriteStream, unlink} from 'fs-extra';
import request, {Headers} from 'request';
import {makeTypedError} from 'typed-errors';

export const UnauthorizedRequestException = makeTypedError('UnauthorizedRequestException');
import {UnauthorizedRequestException} from '@diez/cli';

export const performGetRequestWithBearerToken = <T>(uri: string, token: string): Promise<T> => {
return performGetRequest<T>(uri, true, {Authorization: `Bearer ${token}`});
Expand Down
File renamed without changes.

0 comments on commit 6daed20

Please sign in to comment.