{"record":{"id":"3644906f9a0e5efd","repo":"permissions-dispatcher/PermissionsDispatcher","slug":"method-e-simplestring-must-not-have-any","errorCode":null,"errorMessage":"Method '${e.simpleString()}()' must not have any 'throws' declaration in its signature","messagePattern":"Method '(.+?)\\(\\)' must not have any 'throws' declaration in its signature","errorType":"validation","errorClass":"NoThrowsAllowedException","httpStatus":null,"severity":"error","filePath":"processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt","lineNumber":86,"sourceCode":"            throw PrivateMethodException(it, annotationClass)\n        }\n    }\n}\n\n/**\n * Checks the return type of the elements in the provided list.\n * <p>\n * Raises an exception if any element specifies a return type other than 'void'.\n */\nfun checkMethodSignature(items: List<ExecutableElement>) {\n    items.forEach {\n        // Allow 'void' return type only\n        if (it.returnType.kind != TypeKind.VOID) {\n            throw WrongReturnTypeException(it)\n        }\n        // Allow methods without 'throws' declaration only\n        if (it.thrownTypes.isNotEmpty()) {\n            throw NoThrowsAllowedException(it)\n        }\n    }\n}\n\nfun checkMethodParameters(items: List<ExecutableElement>, numParams: Int, requiredType: TypeMirror? = null) {\n    items.forEach {\n        val params = it.parameters\n        if (numParams == 0 && params.isNotEmpty()) {\n            throw NoParametersAllowedException(it)\n        }\n        if (requiredType == null) {\n            return\n        }\n        if (numParams < params.size) {\n            throw WrongParametersException(it, numParams, requiredType)\n        }\n        // maximum params size is 1\n        params.forEach { param ->","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/74b532bf1fe430fb12ad8414b80399f2d7cfc954/processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt#L68-L104","documentation":"Thrown by checkMethodSignature in Validators.kt:86 via NoThrowsAllowedException. Annotated permission methods must not declare checked exceptions (throws clauses); the generated code calls these methods directly and the library does not propagate or wrap checked exceptions.","triggerScenarios":"Annotated method declared with a throws clause, e.g. void showCamera() throws IOException annotated with @NeedsPermission.","commonSituations":"Annotating an IO-heavy Java method that already throws checked exceptions; Kotlin interop with @Throws annotated functions; legacy methods retrofitted with permission annotations.","solutions":["Remove the throws declaration and handle exceptions inside the method with try/catch.","Wrap the throwing code so no checked exception escapes the method signature.","Remove @Throws in Kotlin so the generated Java signature has no throws clause."],"exampleFix":"// before\n@NeedsPermission(Manifest.permission.CAMERA)\n@Throws(IOException::class)\nfun showCamera() { ... }\n\n// after\n@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() {\n    try { ... } catch (e: IOException) { /* handle */ }\n}","handlingStrategy":"validation","validationCode":"@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() { try { riskyIo() } catch (e: IOException) { } }","typeGuard":null,"tryCatchPattern":"try {\n    build()\n} catch (e: CompilationError) {\n    logger.error(\"Remove throws declarations from permission-annotated methods\", e)\n}","preventionTips":["Handle checked exceptions inside the method body.","Avoid @Throws on annotated Kotlin functions.","Keep annotated method signatures minimal."],"tags":["kotlin","annotation-processor","throws"],"backgroundTag":"invalid-argument-value","analyzedSha":"74b532bf1fe430fb12ad8414b80399f2d7cfc954","analyzedAt":"2026-09-08T21:44:58.380Z","contentChangedAt":"2026-09-08T21:44:58.380Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}