mirror of
https://github.com/sensebox/blockly-app
synced 2025-12-03 14:47:55 +01:00
improve error message on compilation
This commit is contained in:
parent
3c1b9d1044
commit
b1fa8eca0a
2 changed files with 22 additions and 32 deletions
|
|
@ -156,7 +156,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
private async handleUpload () {
|
private async handleUpload () {
|
||||||
this.state.upload = 'uploading'
|
this.state.upload = 'uploading'
|
||||||
try {
|
try {
|
||||||
const res = await this.otaWifi.uploadFirmware(this.sketch)
|
const res = await this.otaWifi.uploadFirmware(this.compiledSketch)
|
||||||
console.log(JSON.stringify(res, null, 2))
|
console.log(JSON.stringify(res, null, 2))
|
||||||
|
|
||||||
this.state.upload = 'done'
|
this.state.upload = 'done'
|
||||||
|
|
@ -169,13 +169,9 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async compileSketch () {
|
private async compileSketch () {
|
||||||
// TODO: implement. use this.sketch
|
|
||||||
|
|
||||||
this.state.compilation = 'compiling'
|
this.state.compilation = 'compiling'
|
||||||
try {
|
try {
|
||||||
this.compiledSketch = await this.compilerprovider.callcompiler(this.sketch)
|
this.compiledSketch = await this.compilerprovider.callcompiler(this.sketch)
|
||||||
console.log((this.compiledSketch))
|
|
||||||
|
|
||||||
this.state.compilation = 'done'
|
this.state.compilation = 'done'
|
||||||
this.slides.lockSwipeToNext(false)
|
this.slides.lockSwipeToNext(false)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
import { HttpClient,HttpHeaders } from '@angular/common/http';
|
import { HttpClient,HttpHeaders } from '@angular/common/http';
|
||||||
import { Http, Headers, RequestOptions } from '@angular/http';
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { BindingFlags } from '@angular/core/src/view';
|
|
||||||
|
|
||||||
/*
|
const URL = "https://compiler.sensebox.de"
|
||||||
Generated class for the CompilerProvider provider.
|
|
||||||
|
|
||||||
See https://angular.io/guide/dependency-injection for more info on providers
|
|
||||||
and Angular DI.
|
|
||||||
*/
|
|
||||||
const url = "https://compiler.sensebox.de"
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CompilerProvider {
|
export class CompilerProvider {
|
||||||
|
|
@ -18,20 +10,22 @@ export class CompilerProvider {
|
||||||
console.log('Hello CompilerProvider Provider');
|
console.log('Hello CompilerProvider Provider');
|
||||||
}
|
}
|
||||||
|
|
||||||
async callcompiler(sketch : string): Promise<any> {
|
async callcompiler(sketch : string): Promise<any> {
|
||||||
let Headers = new HttpHeaders({'Content-Type': 'application/json'} );
|
const headers = new HttpHeaders({'Content-Type': 'application/json'} );
|
||||||
|
const data = { board: 'sensebox-mcu', sketch }
|
||||||
|
|
||||||
/*let options = new RequestOptions({ headers: headers });*/
|
// send compilation request, returning a job ID
|
||||||
|
return this.http.post(`${URL}/compile`, data, { headers }).toPromise()
|
||||||
let data ={"board":"sensebox-mcu", "sketch":sketch}
|
.catch(err => {
|
||||||
return this.http.post(`${url}/compile`, data,{ headers:new HttpHeaders({'Content-Type': 'application/json'} ) })
|
let msg = ''
|
||||||
.toPromise()
|
try { msg = JSON.parse(err.error.message).process } catch (err) {}
|
||||||
.then((response:any) =>{
|
throw new Error(msg || err)
|
||||||
console.log('API Response : ', response.data.id);
|
|
||||||
return this.http.get(`${url}/download?id=${response.data.id}&board=sensebox-mcu`,{
|
|
||||||
responseType: 'text',
|
|
||||||
})
|
})
|
||||||
.toPromise()
|
.then((response:any) =>{
|
||||||
|
// download the resulting sketch binary
|
||||||
|
return this.http.get(`${URL}/download?id=${response.data.id}&board=sensebox-mcu`, {
|
||||||
|
responseType: 'text',
|
||||||
|
}).toPromise()
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue