Просмотр исходного кода

mol-state/task: use console.error only when not in production mode

David Sehnal 5 лет назад
Родитель
Сommit
c5e2471f34
2 измененных файлов с 4 добавлено и 6 удалено
  1. 2 1
      src/mol-state/state.ts
  2. 2 5
      src/mol-task/execution/observable.ts

+ 2 - 1
src/mol-state/state.ts

@@ -20,6 +20,7 @@ import { now, formatTimespan } from '../mol-util/now';
 import { ParamDefinition } from '../mol-util/param-definition';
 import { StateTreeSpine } from './tree/spine';
 import { AsyncQueue } from '../mol-util/async-queue';
+import { isProductionMode } from '../mol-util/debug'
 
 export { State }
 
@@ -586,7 +587,7 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) {
         ctx.changed = true;
         if (!ctx.hadError) ctx.newCurrent = root;
         doError(ctx, root, e, false);
-        console.error(e);
+        if (!isProductionMode) console.error(e);
         return;
     }
 

+ 2 - 5
src/mol-task/execution/observable.ts

@@ -10,6 +10,7 @@ import { Progress } from './progress'
 import { now } from '../../mol-util/now';
 import { Scheduler } from '../util/scheduler'
 import { UserTiming } from '../util/user-timing'
+import { isProductionMode } from '../../mol-util/debug'
 
 interface ExposedTask<T> extends Task<T> {
     f: (ctx: RuntimeContext) => Promise<T>,
@@ -30,10 +31,6 @@ export function ExecuteObservableChild<T>(ctx: RuntimeContext, task: Task<T>, pr
     return (ctx as ObservableRuntimeContext).runChild(task as ExposedTask<T>, progress);
 }
 
-export namespace ExecuteObservable {
-    export let PRINT_ERRORS_TO_STD_ERR = false;
-}
-
 function defaultProgress(task: Task<any>): Task.Progress {
     return {
         taskId: task.id,
@@ -112,7 +109,7 @@ async function execute<T>(task: ExposedTask<T>, ctx: ObservableRuntimeContext) {
                 task.onAbort();
             }
         }
-        if (ExecuteObservable.PRINT_ERRORS_TO_STD_ERR) console.error(e);
+        if (!isProductionMode) console.error(e);
         throw e;
     }
 }