Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Jun 18, 2024
1 parent 183b36a commit 255d722
Show file tree
Hide file tree
Showing 11 changed files with 3,469 additions and 3,570 deletions.
6,901 changes: 3,441 additions & 3,460 deletions apps/tutorial/application.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions apps/tutorial/application.js.map

Large diffs are not rendered by default.

40 changes: 5 additions & 35 deletions apps/tutorial/serviceworker.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions apps/tutorial/serviceworker.js.map

Large diffs are not rendered by default.

50 changes: 0 additions & 50 deletions packages/common/src/detailed-error.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from './angle-parser'
export * from './complex'
export * from './config'
export * from './detailed-error'
export * from './emit-event'
export * from './format'
export * from './number-formatter'
Expand Down
4 changes: 2 additions & 2 deletions packages/elements/src/angle-slider-element.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DetailedError, Util, angleDenominator, radian as radianOf} from '@qni/common'
import {Util, angleDenominator, radian as radianOf} from '@qni/common'
import {attr, controller} from '@github/catalyst'
import {createMachine, interpret} from 'xstate'
import {html, render} from '@github/jtml'
Expand Down Expand Up @@ -65,7 +65,7 @@ export class AngleSliderElement extends HTMLElement {
actions: {
validateDenominator: () => {
if (!Number.isInteger(this.denominator) || this.denominator <= 0) {
throw new DetailedError('Bad denominator', this.denominator)
throw new Error(`Bad denominator: ${this.denominator}`)
}
},
setDenominatorByAngle: (_context, event) => {
Expand Down
14 changes: 7 additions & 7 deletions packages/elements/src/circle-notation-element.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Complex, DetailedError, Util} from '@qni/common'
import {Complex, Util} from '@qni/common'
import {attr, controller, target, targets} from '@github/catalyst'
import {html, render} from '@github/jtml'
import tippy, {Instance, ReferenceElement} from 'tippy.js'
Expand Down Expand Up @@ -198,7 +198,7 @@ export class CircleNotationElement extends HTMLElement {
break
}
default:
throw new DetailedError('unsupported qubit count', this.qubitCount)
throw new Error(`unsupported qubit count: ${this.qubitCount}`)
}
}

Expand Down Expand Up @@ -307,7 +307,7 @@ export class CircleNotationElement extends HTMLElement {
break
}
default:
throw new DetailedError('unsupported qubit count', this.qubitCount)
throw new Error(`unsupported qubit count: ${this.qubitCount}`)
}
}

Expand Down Expand Up @@ -575,7 +575,7 @@ export class CircleNotationElement extends HTMLElement {
}
}
default:
throw new DetailedError('unsupported qubit count', this.qubitCount)
throw new Error(`unsupported qubit count: ${this.qubitCount}`)
}
}

Expand Down Expand Up @@ -646,7 +646,7 @@ export class CircleNotationElement extends HTMLElement {
return this.qubitCircleSizePx * 32 + this.gap * 31
}
default:
throw new DetailedError('unsupported qubit count', this.qubitCount)
throw new Error(`unsupported qubit count: ${this.qubitCount}`)
}
}

Expand Down Expand Up @@ -773,7 +773,7 @@ export class CircleNotationElement extends HTMLElement {
return 16
}
default:
throw new DetailedError('unsupported qubit count', this.qubitCount)
throw new Error(`unsupported qubit count: ${this.qubitCount}`)
}
}

Expand Down Expand Up @@ -1011,7 +1011,7 @@ export class CircleNotationElement extends HTMLElement {
return 1
}
default:
throw new DetailedError('unsupported qubit count', this.qubitCount)
throw new Error(`unsupported qubit count: ${this.qubitCount}`)
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/elements/src/circuit-editor-element.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Angleable, Flaggable, Ifable, isAngleable, isDraggable, isIfable, isMenuable, isResizeable} from './mixin'
import {CircuitStepElement, isCircuitStepElement} from './circuit-step-element'
import {Config, DetailedError, Util, isResizeableSpan} from '@qni/common'
import {Config, Util, isResizeableSpan} from '@qni/common'
import {Operation, isOperation} from './operation'
import {attr, controller, target} from '@github/catalyst'
import {createMachine, interpret} from 'xstate'
Expand Down Expand Up @@ -435,7 +435,7 @@ export class CircuitEditorElement extends HTMLElement {
if (isDraggable(el)) {
el.draggable = true
} else {
throw new DetailedError('Not a draggable element.', {el})
throw new Error(`Not a draggable element: ${el}`)
}
}

Expand All @@ -445,7 +445,7 @@ export class CircuitEditorElement extends HTMLElement {
if (isResizeable(el)) {
el.resizeable = true
} else {
throw new DetailedError('Not a resizeable element.', {el})
throw new Error(`Not a resizeable element: ${el}`)
}
}

Expand Down
3 changes: 1 addition & 2 deletions packages/elements/src/circuit-step-element.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Config,
DetailedError,
ResizeableSpan,
SerializedCircuitStep,
SerializedHGate,
Expand Down Expand Up @@ -1341,7 +1340,7 @@ export class CircuitStepElement extends HTMLElement {
break
}
default:
throw new DetailedError('Unrecognized operation', {klass})
throw new Error(`Unrecognized operation: ${klass}`)
}
}
return serializedStep
Expand Down
4 changes: 2 additions & 2 deletions packages/elements/src/quantum-simulator-element.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Complex, DetailedError, Util} from '@qni/common'
import {Complex, Util} from '@qni/common'
import {attr, controller, target, targets} from '@github/catalyst'
import {html, render} from '@github/jtml'
import {isBlochDisplayElement, isMeasurementGateElement} from './operation'
Expand Down Expand Up @@ -130,7 +130,7 @@ export class QuantumSimulatorElement extends HTMLElement {
break
}
default:
throw new DetailedError('Unknown service worker message', {data})
throw new Error(`Unknown service worker message: ${data}`)
}
}

Expand Down

0 comments on commit 255d722

Please sign in to comment.