Skip to content

Commit

Permalink
Better handling of errors when trying to edit an API. Fixes #337
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Wittmann <eric.wittmann@gmail.com>
  • Loading branch information
EricWittmann committed Jul 12, 2018
1 parent 37e362f commit 0cf9e4c
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class VerticalNavComponent implements OnInit {
constructor(private router: Router) {}

ngOnInit(): void {
console.log("Subscribing to router events.");
this.router.events.subscribe(event => {
if (event instanceof NavigationStart) {
this.onShadeClick();
Expand Down
1 change: 0 additions & 1 deletion front-end/studio/src/app/pages/apis/apis.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export class ApisPageComponent extends AbstractPageComponent implements OnDestro
public loadAsyncPageData(): void {
console.log("[ApisPageComponent] loadAsyncPageData")
this.apis.getApis().then( apis => {
console.info("APIS: %O", apis);
this.allApis = apis;
this.filterApis();
this.loaded("apis");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export class ImportApiFormComponent {
try {
importApi.data = Base64Utils.encode(this.model.data);
} catch (e) {
console.info("*** Failed to fire IMPORT event. ***");
console.error(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,9 @@ export class SecurityScheme30DialogComponent {
* @return
*/
private toScopesArray(scopes: any): Scope[] {
console.info("toScopesArray: %o", scopes);
let rval: Scope[] = [];
if (scopes) {
for (let sk in scopes) {
console.info(" " + sk);
let sd: string = scopes[sk]
rval.push({
name: sk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,12 @@ export abstract class SourceFormComponent<T extends OasNode> {
}

public revertSource(): void {
console.info("Reverting source");
let originalSource: string;
if (this._sourceFormat === CodeEditorMode.YAML) {
originalSource = YAML.stringify(this.sourceJs(), 100, 4);
} else {
originalSource = JSON.stringify(this.sourceJs(), null, 4);
}
console.info("this.source = originalSource");
this.source = originalSource;
this._source.dirty = false;
this._source.value = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export class ApiEditorPageComponent extends AbstractPageComponent implements Aft
});
},
onSelection: (user, selection) => {
console.info("User %s selection changed to: %s", user.userName, selection);
this.zone.run(() => {
__component.updateSelection(user, selection);
});
Expand Down Expand Up @@ -180,7 +179,6 @@ export class ApiEditorPageComponent extends AbstractPageComponent implements Aft
public ngAfterViewInit(): void {
this._apiEditor.changes.subscribe( () => {
if (this._apiEditor.first) {
console.info("Editor is available!");
this._pendingCommands.subscribe( commands => {
this.pendingCommands = [];
commands.forEach( command => {
Expand All @@ -205,7 +203,9 @@ export class ApiEditorPageComponent extends AbstractPageComponent implements Aft
* Called when the page is destroyed.
*/
public ngOnDestroy(): void {
this.editingSession.close();
if (this.editingSession) {
this.editingSession.close();
}
}

/**
Expand Down
5 changes: 2 additions & 3 deletions front-end/studio/src/app/services/apis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,8 @@ export class ApisService extends AbstractHubService {

return def;
}).toPromise();
}, () => {
// TODO handle an error here!
return null;
}, error => {
return Promise.reject(error);
});
}

Expand Down

0 comments on commit 0cf9e4c

Please sign in to comment.