diff --git a/src/commands/create.command.ts b/src/commands/create.command.ts index 46c65e0f729..41a216d8713 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 2d532d690fa..e96123e2fff 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 9d132ac6f8b..8938aa6b900 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 d3a0483af14..2cc9eb14211 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 9da7d0b27c4..167db8a2f2a 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 9ac05f6114b..7c05a48ee4c 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 = {