Commit b69b95d2 authored by 神楽坂玲奈's avatar 神楽坂玲奈

error handler

parent dd32aa4e
......@@ -86,7 +86,7 @@ export class AppsService {
let params = new URLSearchParams();
params.set('user_id', this.loginService.user.email);
let data = await this.http.get(appsURL).map((response) => response.json()).toPromise();
let keys_data = await this.http.get(keysURL, {search: params}).map((response) => response.json()).toPromise();
let keys_data = await this.http.get(keysURL, { search: params }).map((response) => response.json()).toPromise();
for (let item of keys_data) {
let app = data.find((app: any) => app.id === item.app_id);
if (app) {
......@@ -99,7 +99,7 @@ export class AppsService {
console.error(e);
let data = localStorage.getItem('apps_json');
if (data) {
this.apps = this.loadAppsList(JSON.parse(data));
this.apps = this.loadAppsList(JSON.parse(data!));
} else {
alert('读取游戏列表失败,可能是网络不通');
this.apps = new Map();
......@@ -360,7 +360,7 @@ export class AppsService {
let checksumFiles = await this.getChecksumFile(app);
for (let [pattern, fileOption] of app.files) {
await new Promise((resolve, reject) => {
new glob.Glob(pattern, {cwd: appPath}, (err, files) => {
new glob.Glob(pattern, { cwd: appPath }, (err, files) => {
for (let file of files) {
// 避免被当做文件夹
if (fileOption.sync) {
......@@ -517,7 +517,7 @@ export class AppsService {
let ignoreFiles: Set<string> = new Set();
for (let [pattern, fileOption] of app.files) {
await new Promise((resolve, reject) => {
new glob.Glob(pattern, {cwd: app.local!.path}, (err, files) => {
new glob.Glob(pattern, { cwd: app.local!.path }, (err, files) => {
for (let file of files) {
if (fileOption.ignore) {
ignoreFiles.add(file);
......@@ -703,7 +703,7 @@ export class AppsService {
}
let files = await this.downloadService.getFiles(downloadId);
_app.status.status = 'waiting';
return {app: _app, files: files};
return { app: _app, files: files };
};
if (!app.isInstalled()) {
let apps: App[] = [];
......@@ -724,7 +724,7 @@ export class AppsService {
for (let result of downloadResults) {
let o = new InstallOption(result.app, option.installLibrary);
o.downloadFiles = result.files;
let task = tryToInstall({app: result.app, option: o});
let task = tryToInstall({ app: result.app, option: o });
installTasks.push(task);
}
await Promise.all(installTasks);
......@@ -770,14 +770,14 @@ export class AppsService {
if (th105.isInstalled()) {
const config_file = path.join((<AppLocal>app.local).path, 'configex123.ini');
let config = await new Promise((resolve, reject) => {
fs.readFile(config_file, {encoding: 'utf-8'}, (error, data) => {
fs.readFile(config_file, { encoding: 'utf-8' }, (error, data) => {
if (error) {
return reject(error);
}
resolve(ini.parse(data));
});
});
config['th105path'] = {path: (<AppLocal>th105.local).path};
config['th105path'] = { path: (<AppLocal>th105.local).path };
await new Promise((resolve, reject) => {
fs.writeFile(config_file, ini.stringify(config), (error) => {
if (error) {
......@@ -798,7 +798,7 @@ export class AppsService {
if (action.open.id === 'np2fmgen') {
const config_file = path.join(action.open!.local!.path, 'np21nt.ini');
let config = await new Promise((resolve, reject) => {
fs.readFile(config_file, {encoding: 'utf-8'}, (error, data) => {
fs.readFile(config_file, { encoding: 'utf-8' }, (error, data) => {
if (error) {
return reject(error);
}
......@@ -845,7 +845,7 @@ export class AppsService {
args = args.concat(action.args);
env = Object.assign(env, action.env);
console.log(execute, args, env, cwd);
let handle = child_process.spawn(execute, args, {env: env, cwd: cwd});
let handle = child_process.spawn(execute, args, { env: env, cwd: cwd });
handle.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
......@@ -872,7 +872,7 @@ export class AppsService {
async network(app: App, server: any) {
if (!this.maotama) {
this.maotama = new Promise((resolve, reject) => {
let child = sudo.fork('maotama', [], {stdio: ['inherit', 'inherit', 'inherit', 'ipc']});
let child = sudo.fork('maotama', [], { stdio: ['inherit', 'inherit', 'inherit', 'ipc'] });
child.once('message', () => resolve(child));
child.once('error', reject);
child.once('exit', reject);
......@@ -890,7 +890,7 @@ export class AppsService {
if (connection) {
connection.connection.close();
}
connection = {connection: new WebSocket(server.url), address: null};
connection = { connection: new WebSocket(server.url), address: null };
let id: Timer | null;
this.connections.set(app, connection);
connection.connection.onmessage = (event) => {
......
/**
* Created by zh99998 on 2017/6/1.
*/
import * as Raven from 'raven-js';
import { ErrorHandler } from '@angular/core';
Raven
.config('https://2c5fa0d0f13c43b5b96346f4eff2ea60@sentry.io/174769')
.install();
export class RavenErrorHandler implements ErrorHandler {
handleError(err: any): void {
Raven.captureException(err.originalError || err);
}
}
\ No newline at end of file
import {NgModule, NO_ERRORS_SCHEMA, LOCALE_ID} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {MyCardComponent} from './mycard.component';
import {LoginComponent} from './login.component';
import {StoreComponent} from './store.component';
import {LobbyComponent} from './lobby.component';
import {AppDetailComponent} from './app-detail.component';
import {RosterComponent} from './roster.component';
import {YGOProComponent} from './ygopro.component';
import {AppsService} from './apps.service';
import {SettingsService} from './settings.sevices';
import {LoginService} from './login.service';
import {DownloadService} from './download.service';
import {AboutComponent} from './about.component';
import {CandyComponent} from './candy.component';
import { ErrorHandler, LOCALE_ID, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { MyCardComponent } from './mycard.component';
import { LoginComponent } from './login.component';
import { StoreComponent } from './store.component';
import { LobbyComponent } from './lobby.component';
import { AppDetailComponent } from './app-detail.component';
import { RosterComponent } from './roster.component';
import { YGOProComponent } from './ygopro.component';
import { AppsService } from './apps.service';
import { SettingsService } from './settings.sevices';
import { LoginService } from './login.service';
import { DownloadService } from './download.service';
import { AboutComponent } from './about.component';
import { CandyComponent } from './candy.component';
import { RavenErrorHandler } from './error-handler';
@NgModule({
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule],
......@@ -29,6 +31,9 @@ import {CandyComponent} from './candy.component';
provide: LOCALE_ID,
deps: [SettingsService],
useFactory: (settingsService: SettingsService) => settingsService.getLocale()
},
{
provide: ErrorHandler, useClass: RavenErrorHandler
}
],
schemas: [NO_ERRORS_SCHEMA]
......
{
"name": "mycard",
"version": "3.0.27",
"version": "3.0.28",
"description": "moecube",
"keywords": [],
"author": "zh99998 <zh99998@gmail.com>",
......@@ -21,6 +21,7 @@
"i18n:download": "curl --output locale/messages.en-US.xlf --retry 5 --location --user ${TRANSIFEX_USERNAME}:${TRANSIFEX_PASSWORD} https://www.transifex.com/api/2/project/moecube/resource/messages/translation/en_US/?file && sed -i.bak 's/\\&amp;/\\&/g; s/\\&lt;/</g; s/\\&gt;/>/g; s/\\&quot;/\"/g;' locale/messages.en-US.xlf"
},
"dependencies": {
"@angular/animations": "^4.1.3",
"@angular/common": "latest",
"@angular/compiler": "latest",
"@angular/core": "latest",
......@@ -35,14 +36,15 @@
"candy": "https://github.com/moecube/candy/releases/download/v2.2.0/candy.tar.gz",
"candy-shop": "candy-chat/candy-plugins",
"core-js": "latest",
"electron-updater": "latest",
"electron-is-dev": "latest",
"electron-sudo": "moecube/electron-sudo#moecube",
"electron-updater": "latest",
"font-awesome": "latest",
"glob": "latest",
"ini": "latest",
"jquery": "latest",
"marked": "latest",
"raven-js": "latest",
"raw-socket": "latest",
"reconnecting-websocket": "latest",
"reflect-metadata": "latest",
......@@ -64,6 +66,7 @@
"@types/bootstrap": "latest",
"@types/jquery": "latest",
"@types/marked": "latest",
"@types/raven-js": "latest",
"@types/tether": "latest",
"@types/typeahead": "latest",
"electron": "latest",
......@@ -89,8 +92,7 @@
}
],
"extraResources": [
"bin",
"images"
"bin"
],
"dmg": {
"contents": [
......
......@@ -77,8 +77,11 @@ System.config({
'jquery': 'npm:jquery/dist/jquery.min.js',
'tether': 'npm:tether/dist/js/tether.min.js',
'bootstrap': 'npm:bootstrap/dist/js/bootstrap.min.js',
'reconnecting-websocket': 'npm:reconnecting-websocket/dist/index.js'
'reconnecting-websocket': 'npm:reconnecting-websocket/dist/index.js',
// 'typeahead.js': '@node/typeahead.js'
'raven-js': 'npm:raven-js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
......@@ -88,6 +91,9 @@ System.config({
},
rxjs: {
defaultExtension: 'js'
},
'raven-js': {
main: 'dist/raven.js'
}
},
meta: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment