From 83e91b70ff343dd27e1cf9b3fa65fcdf651dfe96 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 15 May 2018 11:08:55 -0400 Subject: [PATCH] fix errors --- src/commands/create.command.ts | 4 ++-- src/commands/delete.command.ts | 4 ++-- src/commands/login.command.ts | 2 +- src/commands/sync.command.ts | 2 +- src/models/response.ts | 8 ++++++-- webpack.config.js | 1 + 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/commands/create.command.ts b/src/commands/create.command.ts index 46c65e0..41a216d 100644 --- a/src/commands/create.command.ts +++ b/src/commands/create.command.ts @@ -36,7 +36,7 @@ export class CreateCommand { await this.cipherService.saveWithServer(cipher); return Response.success(); } catch (e) { - return Response.error(e.toString()); + return Response.error(e); } } @@ -46,7 +46,7 @@ export class CreateCommand { await this.folderService.saveWithServer(folder); return Response.success(); } catch (e) { - return Response.error(e.toString()); + return Response.error(e); } } } diff --git a/src/commands/delete.command.ts b/src/commands/delete.command.ts index 2d532d6..e96123e 100644 --- a/src/commands/delete.command.ts +++ b/src/commands/delete.command.ts @@ -29,7 +29,7 @@ export class DeleteCommand { await this.cipherService.deleteWithServer(id); return Response.success(); } catch (e) { - return Response.error(e.toString()); + return Response.error(e); } } @@ -43,7 +43,7 @@ export class DeleteCommand { await this.folderService.deleteWithServer(id); return Response.success(); } catch (e) { - return Response.error(e.toString()); + return Response.error(e); } } } diff --git a/src/commands/login.command.ts b/src/commands/login.command.ts index 9d132ac..8938aa6 100644 --- a/src/commands/login.command.ts +++ b/src/commands/login.command.ts @@ -15,7 +15,7 @@ export class LoginCommand { // TODO: 2FA return Response.success(); } catch (e) { - return Response.success(e.toString()); + return Response.error(e); } } } diff --git a/src/commands/sync.command.ts b/src/commands/sync.command.ts index d3a0483..2cc9eb1 100644 --- a/src/commands/sync.command.ts +++ b/src/commands/sync.command.ts @@ -12,7 +12,7 @@ export class SyncCommand { const result = await this.syncService.fullSync(cmd.force || false); return Response.success(); } catch (e) { - return Response.success(e.toString()); + return Response.error(e); } } } diff --git a/src/models/response.ts b/src/models/response.ts index 9da7d0b..167db8a 100644 --- a/src/models/response.ts +++ b/src/models/response.ts @@ -1,10 +1,14 @@ import { BaseResponse } from './response/baseResponse'; export class Response { - static error(message: string): Response { + static error(error: any): Response { const res = new Response(); res.success = false; - res.message = message; + if (typeof (error) === 'string') { + res.message = error; + } else { + res.message = error.message != null ? error.message : error.toString(); + } return res; } diff --git a/webpack.config.js b/webpack.config.js index 9ac05f6..7c05a48 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -43,6 +43,7 @@ const plugins = [ banner: '#!/usr/bin/env node', raw: true }), + new webpack.IgnorePlugin(/^encoding$/, /node-fetch/), ]; const config = {