Skip to content

Commit

Permalink
Merge pull request #19 from zosconnect/issue/18
Browse files Browse the repository at this point in the history
Handle file loading errors
  • Loading branch information
crshnburn committed Mar 26, 2019
2 parents 3a49d33 + bf049d3 commit 5664d41
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/cli/api/install/install.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { ConnectionUtil } from "../../../connection";
export default class ApiInstallHandler implements ICommandHandler {
public async process(commandParameters: IHandlerParameters) {
const filePath = commandParameters.arguments.file;
const fileBuf = fs.readFileSync(filePath);
let fileBuf;
try {
fileBuf = fs.readFileSync(filePath);
} catch (error) {
commandParameters.response.console.error(`Unable to load AAR file (${error.message})`);
return;
}

const profile = commandParameters.profiles.get("zosconnect");
const session = ConnectionUtil.getSession(profile);
Expand Down
8 changes: 7 additions & 1 deletion src/cli/api/update/update.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { ConnectionUtil } from "../../../connection";
export default class ApiUpdateHander implements ICommandHandler {
public async process(commandParameters: IHandlerParameters) {
const filePath = commandParameters.arguments.file;
const fileBuf = fs.readFileSync(filePath);
let fileBuf;
try {
fileBuf = fs.readFileSync(filePath);
} catch (error) {
commandParameters.response.console.error(`Unable to load AAR file (${error.message})`);
return;
}

const profile = commandParameters.profiles.get("zosconnect");
const session = ConnectionUtil.getSession(profile);
Expand Down
8 changes: 7 additions & 1 deletion src/cli/apirequester/install/install.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { ConnectionUtil } from "../../../connection";
export default class ApiRequsterInstallHandler implements ICommandHandler {
public async process(commandParameters: IHandlerParameters): Promise<void> {
const filePath = commandParameters.arguments.file;
const fileBuf = fs.readFileSync(filePath);
let fileBuf;
try {
fileBuf = fs.readFileSync(filePath);
} catch (error) {
commandParameters.response.console.error(`Unable to load ARA file (${error.message})`);
return;
}

const profile = commandParameters.profiles.get("zosconnect");
const session = ConnectionUtil.getSession(profile);
Expand Down
8 changes: 7 additions & 1 deletion src/cli/apirequester/update/update.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { ConnectionUtil } from "../../../connection";
export default class ApiRequesterUpdateHander implements ICommandHandler {
public async process(commandParameters: IHandlerParameters) {
const filePath = commandParameters.arguments.file;
const fileBuf = fs.readFileSync(filePath);
let fileBuf;
try {
fileBuf = fs.readFileSync(filePath);
} catch (error) {
commandParameters.response.console.error(`Unable to load ARA file (${error.message})`);
return;
}

const profile = commandParameters.profiles.get("zosconnect");
const session = ConnectionUtil.getSession(profile);
Expand Down
8 changes: 7 additions & 1 deletion src/cli/service/install/install.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { ConnectionUtil } from "../../../connection";
export default class ServiceInstallHandler implements ICommandHandler {
public async process(commandParameters: IHandlerParameters): Promise<void> {
const filePath = commandParameters.arguments.file;
const fileBuf = fs.readFileSync(filePath);
let fileBuf;
try {
fileBuf = fs.readFileSync(filePath);
} catch (error) {
commandParameters.response.console.error(`Unable to load SAR file (${error.message})`);
return;
}

const profile = commandParameters.profiles.get("zosconnect");
const session = ConnectionUtil.getSession(profile);
Expand Down
8 changes: 7 additions & 1 deletion src/cli/service/update/update.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { ConnectionUtil } from "../../../connection";
export default class UpdateHandler implements ICommandHandler {
public async process(commandParameters: IHandlerParameters): Promise<void> {
const filePath = commandParameters.arguments.file;
const fileBuf = fs.readFileSync(filePath);
let fileBuf;
try {
fileBuf = fs.readFileSync(filePath);
} catch (error) {
commandParameters.response.console.error(`Unable to load SAR file (${error.message})`);
return;
}

const profile = commandParameters.profiles.get("zosconnect");
const session = ConnectionUtil.getSession(profile);
Expand Down

0 comments on commit 5664d41

Please sign in to comment.