-
Notifications
You must be signed in to change notification settings - Fork 37
Improve Exception to NSError conversion #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rickclephas
wants to merge
23
commits into
master
Choose a base branch
from
feature/GH-29-improve-exception-conversion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e39f2f0
Update asNSError to use KN runtime functions
rickclephas a61b5c3
Update compiler to support exception propagation
rickclephas 32946d4
Always propagate CancellationExceptions
rickclephas 115e147
Use custom BestExceptionEver
rickclephas e97ae38
Improve NSError tests
rickclephas 118f814
Add compiler tests for exceptions
rickclephas c22943c
Add compiler tests for Flow value and replayCache
rickclephas f369d5d
Merge branch 'master' into feature/GH-29-improve-exception-conversion
rickclephas 2218d3d
Remove unnecessary default propagatedException
rickclephas 64b1fb8
Support NativeCoroutineThrows annotation on classes
rickclephas 0cb1ba5
Update README with exception propagation info
rickclephas 3c6d768
Fix tests
rickclephas 4781c30
Merge branch 'master' into feature/GH-29-improve-exception-conversion
rickclephas e99ddef
Merge branch 'master' into feature/GH-29-improve-exception-conversion
rickclephas 7644c0b
Update asNativeError function with propagatedExceptions
rickclephas e908241
Code cleanup
rickclephas 9c92d44
Use NSErrorKt
rickclephas a2aae28
Revert to Throws annotation
rickclephas dade444
Update tests for asNativeError
rickclephas 3874964
Merge branch 'master' into feature/GH-29-improve-exception-conversion
rickclephas fc884ee
Fix tests after merge
rickclephas cf07edc
Always propagate CancellationExceptions
rickclephas 3099f82
Add local maven repo to sample
rickclephas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...tions/src/commonMain/kotlin/com/rickclephas/kmp/nativecoroutines/NativeCoroutineThrows.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.rickclephas.kmp.nativecoroutines | ||
|
|
||
| import kotlin.reflect.KClass | ||
|
|
||
| /** | ||
| * Defines what exceptions should be propagated as `NSError`s. | ||
| * | ||
| * Exceptions which are instances of one of the [exceptionClasses] or their subclasses, | ||
| * are propagated as a `NSError`s. | ||
| * Other Kotlin exceptions are considered unhandled and cause program termination. | ||
| * | ||
| * @see Throws | ||
| */ | ||
| @Target(AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.FUNCTION, AnnotationTarget.CLASS) | ||
| @Retention(AnnotationRetention.SOURCE) | ||
| @MustBeDocumented | ||
| annotation class NativeCoroutineThrows(vararg val exceptionClasses: KClass<out Throwable>) |
7 changes: 7 additions & 0 deletions
7
...rc/main/kotlin/com/rickclephas/kmp/nativecoroutines/compiler/CompilerConfigurationKeys.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| package com.rickclephas.kmp.nativecoroutines.compiler | ||
|
|
||
| import org.jetbrains.kotlin.config.CompilerConfigurationKey | ||
| import org.jetbrains.kotlin.name.FqName | ||
|
|
||
| internal const val SUFFIX_OPTION_NAME = "suffix" | ||
| internal val SUFFIX_KEY = CompilerConfigurationKey<String>(SUFFIX_OPTION_NAME) | ||
|
|
||
| internal const val PROPAGATED_EXCEPTIONS_OPTION_NAME = "propagatedExceptions" | ||
| internal val PROPAGATED_EXCEPTIONS_KEY = CompilerConfigurationKey<List<FqName>>(PROPAGATED_EXCEPTIONS_OPTION_NAME) | ||
|
|
||
| internal const val USE_THROWS_ANNOTATION_OPTION_NAME = "useThrowsAnnotation" | ||
| internal val USE_THROWS_ANNOTATION_KEY = CompilerConfigurationKey<Boolean>(USE_THROWS_ANNOTATION_OPTION_NAME) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...compiler/src/main/kotlin/com/rickclephas/kmp/nativecoroutines/compiler/utils/IrArrayOf.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.rickclephas.kmp.nativecoroutines.compiler.utils | ||
|
|
||
| import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope | ||
| import org.jetbrains.kotlin.ir.builders.irCall | ||
| import org.jetbrains.kotlin.ir.expressions.IrExpression | ||
| import org.jetbrains.kotlin.ir.expressions.IrVarargElement | ||
| import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl | ||
| import org.jetbrains.kotlin.ir.types.IrType | ||
| import org.jetbrains.kotlin.ir.types.typeWith | ||
|
|
||
| internal fun IrBuilderWithScope.irArrayOf( | ||
| elementType: IrType, | ||
| elements: List<IrVarargElement> | ||
| ): IrExpression { | ||
| val arrayType = context.irBuiltIns.arrayClass.typeWith(elementType) | ||
| val vararg = IrVarargImpl(startOffset, endOffset, arrayType, elementType, elements) | ||
| return irCall(context.irBuiltIns.arrayOf, arrayType, listOf(elementType)).apply { | ||
| putValueArgument(0, vararg) | ||
| } | ||
| } |
23 changes: 0 additions & 23 deletions
23
...ines-compiler/src/main/kotlin/com/rickclephas/kmp/nativecoroutines/compiler/utils/List.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should just use all the annotations, would probably make more sense since the
propagatedExceptionsare also applied (even if the function has an annotation).