Vampire
08/21/2020, 11:05 AMtry {
/* ... */
} catch (error) {
if (error.name === cache.ValidationError.name) {
throw error
} else if (error.name === cache.ReserveCacheError.name) {
<http://core.info|core.info>(error.message)
} else {
core.warning(error.message)
}
}
turansky
08/21/2020, 11:14 AMVampire
08/21/2020, 11:17 AMtypealias ValidationError = Error
typealias ReserveCacheError = Error
try {
/* ... */
} catch (e: ValidationError) {
throw e
} catch (e: ReserveCacheError) {
info(e.message ?: "$e")
} catch (e: Error) {
val message = e.message
if (message == null) {
warning(e)
} else {
warning(message)
}
}
or similarturansky
08/21/2020, 11:18 AMVampire
08/21/2020, 11:26 AMTobias Berger
08/21/2020, 12:55 PMtry {
/* ... */
} catch (error) {
when(error) {
is ValidationError -> throw error
is ReserveCacheError -> <http://core.info|core.info>(error.message)
else -> core.warning(error.message)
}
}
Tobias Berger
08/21/2020, 12:56 PM...
when(error.name) {
cache.ValidationError.name -> ...
...
Vampire
08/21/2020, 1:03 PMVampire
08/21/2020, 1:11 PM[JB] Shagen
08/21/2020, 1:14 PMVampire
08/21/2020, 1:15 PM@JsModule
annotation.
Maybe that's why it was also not moved out to a separate file.
I added the @JsModule
and removed the `typealias`es to made it compile properlyVampire
08/21/2020, 1:16 PM@actions/...
have no @JsModule
but someone said this is already reported somewhere. In this case it is @actions/cache
turansky
08/21/2020, 1:17 PMwhen
will be most compact and readableVampire
08/21/2020, 1:18 PMError
has no name
propertyturansky
08/21/2020, 1:19 PMdynamic
has :)Vampire
08/21/2020, 1:20 PMdynamic
has them all 😄Vampire
08/21/2020, 1:21 PMError
interface in lib.es5.d.ts
actually has a name
propertyVampire
08/21/2020, 9:53 PMtry {
/* ... */
} catch (e: ValidationError) {
throw e
} catch (e: ReserveCacheError) {
info(e.message ?: "$e")
} catch (e: Throwable) {
val message = e.message
if (message == null) {
if (e is Error) {
warning(e)
} else {
warning("$e")
}
} else {
warning(message)
}
}
@[JB] Shagen the main problem is not that the `typealias`es were in the same file.
The main problem is, that they are actually `typealias`es.
I now replace typealias ValidationError = Error
by external class ValidationError : Throwable
and typealias ReserveCacheError = Error
by external class ReserveCacheError : Throwable
and now I can properly use multiple catch clauses for the different exceptions.
And even if the `typealias`es would be ok, what they alias is not.
afaiu JavaScript Error
is translated to Kotlin Throwable
, so the type aliases should alias Throwable
, not Error
.
Anyway, before with the `typealias`es all if
-branches checked for the exception being an instance of Error
(Kotlin) which of course failed.
Now the generated if
-cascade is working properly.turansky
08/22/2020, 1:44 AMactually multi-catch is supportedYes, my bad 😞 Multicatch in multicatch - KT-7128
Vampire
08/22/2020, 2:07 AMVampire
09/04/2020, 9:51 AMturansky
09/05/2020, 6:23 PMget/set
declarations are redundant here and can be removedturansky
09/05/2020, 6:31 PMVampire
09/06/2020, 2:06 AMturansky
09/06/2020, 7:09 AMI adapted to what Dukat generates.Dukat generate redundant code 😞
turansky
09/06/2020, 7:14 AMWhere didn’t I follow Kotlin code conventions?Parameter formatting for example. Indent - 8 spaces (convention - 4) I saw the same bug IDEA 2020.1
turansky
09/09/2020, 10:45 PMVampire
09/10/2020, 8:35 AMVampire
09/26/2020, 12:17 AMturansky
09/26/2020, 10:12 PMVampire
09/29/2020, 10:38 AM