Fix error handling to include thrown voids.

This commit is contained in:
gozala 2016-05-10 09:27:30 -07:00
Родитель 94247d4990
Коммит f1ade5e9db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C80F9B292FB470DE
3 изменённых файлов: 13 добавлений и 8 удалений

Просмотреть файл

@ -10,6 +10,7 @@ export type {Text, Key, TagName, DOM}
*/ */
let driver/*:?Driver*/ = null let driver/*:?Driver*/ = null
const absent = new String("absent")
class VirtualRoot /*::<model, action>*/ { class VirtualRoot /*::<model, action>*/ {
/*:: /*::
@ -29,7 +30,7 @@ class VirtualRoot /*::<model, action>*/ {
this.address = address this.address = address
} }
renderWith(current/*:Driver*/) { renderWith(current/*:Driver*/) {
let exception = null let exception = absent
const previous = driver const previous = driver
driver = current driver = current
@ -42,7 +43,7 @@ class VirtualRoot /*::<model, action>*/ {
driver = previous driver = previous
if (exception != null) { if (exception != absent) {
throw exception throw exception
} }
} }

Просмотреть файл

@ -18,6 +18,8 @@ let state/*:State*/ = NO_REQUEST
let requests/*:Array<(time:Time) => any>*/ = [] let requests/*:Array<(time:Time) => any>*/ = []
let ids/*:Array<number>*/ = [] let ids/*:Array<number>*/ = []
const absent = new String("absent")
export const requestAnimationFrame = /*::<a>*/ export const requestAnimationFrame = /*::<a>*/
(request/*:(time:Time) => a*/) => { (request/*:(time:Time) => a*/) => {
if (state === NO_REQUEST) { if (state === NO_REQUEST) {
@ -76,7 +78,7 @@ const dispatchAnimationFrame = /*::<a>*/
, index/*:number*/ , index/*:number*/
, time/*:Time*/ , time/*:Time*/
) => { ) => {
let exception = null let exception = absent
const count = requests.length const count = requests.length
try { try {
while (index < count) { while (index < count) {
@ -93,7 +95,7 @@ const dispatchAnimationFrame = /*::<a>*/
dispatchAnimationFrame(requests, index, time) dispatchAnimationFrame(requests, index, time)
} }
if (exception != null) { if (exception != absent) {
throw exception throw exception
} }
} }

Просмотреть файл

@ -9,6 +9,8 @@ export type {Signal, Address, Mailbox}
export type {Translate, Reducer, AddressBook} export type {Translate, Reducer, AddressBook}
*/ */
const absent = new String("absent")
class Input /*::<a>*/ { class Input /*::<a>*/ {
/*:: /*::
$type: "Signal.Signal"; $type: "Signal.Signal";
@ -29,7 +31,7 @@ class Input /*::<a>*/ {
} }
} }
static notify(message/*:a*/, addressBook/*:AddressBook<a>*/, from/*:number*/, to/*:number*/)/*:void*/ { static notify(message/*:a*/, addressBook/*:AddressBook<a>*/, from/*:number*/, to/*:number*/)/*:void*/ {
let exception = null let exception = absent
try { try {
while (from < to) { while (from < to) {
const address = addressBook[from] const address = addressBook[from]
@ -47,7 +49,7 @@ class Input /*::<a>*/ {
Input.notify(message, addressBook, from + 1, to) Input.notify(message, addressBook, from + 1, to)
} }
if (exception != null) { if (exception != absent) {
throw exception throw exception
} }
} }
@ -82,7 +84,7 @@ class Input /*::<a>*/ {
this.queue.push(value) this.queue.push(value)
} }
} else { } else {
let exception = null let exception = absent
this.isBlocked = true this.isBlocked = true
try { try {
this.value = value this.value = value
@ -101,7 +103,7 @@ class Input /*::<a>*/ {
this.receive(value = this.queue.shift()) this.receive(value = this.queue.shift())
} }
if (exception != null) { if (exception != absent) {
throw exception throw exception
} }
} }