草庐IT

must_raise

全部标签

mongodb - 为什么我收到错误 "db_name must be a string or symbol"?

快速版本(对于那些熟悉Mongoid和Sinatra的人):如果它不是Psyche/SyckYAML解析问题,为什么在尝试使用Mongoid连接到MongoDB数据库时可能会出现此错误?(或者也许它是那个问题,在这种情况下,我该如何修复我的mongoid.yml文件,发布在下面?)更详细的(原始)版本:我有一个Sinatra应用程序通过Mongoid与MongoDB数据库交互:configuredoMongoid.load!('config/mongoid.yml')end我的mongoid.yml文件如下所示:development:host:localhostdatabase:pr

android - Kotlin Realm : Class must declare a public constructor with no arguments if it contains custom constructors

我正在Kotlin中创建一个Realm对象。Realm对象:openclassPurposeModel(var_id:Long?,varpurposeEn:String?,varpurposeAr:String?):RealmObject()当我编译上面的代码时,我得到了这个错误:error:Class"PurposeModel"mustdeclareapublicconstructorwithnoargumentsifitcontainscustomconstructors.我在Kotlin中找不到任何与此相关的问题。我该如何解决这个问题? 最佳答案

kotlin - 委派给初始化属性时出现 "Variable must be initialized"错误

objectFoo:CharSequencebyFoo.X{valX=""}产生Variable'X'mustbeinitialized但确实如此!并且代码应该翻译成类似objectFoo:CharSequence{valX=""overridevallengthget()=Foo.X.lengthoverrideoperatorfunget(index:Int):Char=Foo.X[index]overridefunsubSequence(startIndex:Int,endIndex:Int)=Foo.X.subSequence(startIndex,endIndex)}效果很好

java - Kotlin 中的错误 "must not be null"

.zip文件中有多个文件,我正在尝试获取这些文件。尝试解压缩文件会提供java.lang.IllegalStateException:zis.nextEntrymustnotbenull。怎么做才是正确的?@Throws(IOException::class)fununzip(zipFile:File,targetDirectory:File){valzis=ZipInputStream(BufferedInputStream(FileInputStream(zipFile)))try{varze:ZipEntryvarcount:Intvalbuffer=ByteArray(8192

android - Kotlin 属性 : "Type parameter of a property must be used in its receiver type"

我有以下简单的Kotlin扩展函数://GettheviewsofViewGroupinlinevalViewGroup.views:Listget()=(0..childCount-1).map{getChildAt(it)}//GettheviewsofViewGroupofgiventypeinlinefunViewGroup.getViewsOfType():List{returnthis.views.filterIsInstance()}这段代码可以编译并且运行良好。但是,我希望函数getViewsOfType成为一个属性,就像views一样。AndroidStudio甚至建

oop - Kotlin: 'This type has a constructor and thus must be initialized here' ,但没有声明构造函数

最近开始使用Kotlin根据Kotlin文档,可以有一个主构造函数和一个或多个辅助构造函数。我不明白为什么我会看到这个错误由于类test没有主构造函数。这很好用:openclasstest{}classtest2:test(){}这是我遇到的另一个困难,当我定义辅助构造函数时,IDE显示另一个错误提示Supertypeinitializationisimpossiblewithoutprimaryconstructor但在前面的工作示例中,我确实对其进行了初始化,但它运行良好。我做错了什么? 最佳答案 您会收到此错误,因为即使您没有

android - Kotlin 中的 Retrofit2 + SimpleXML : MethodException: Annotation must mark a set or get method

我想通过在Kotlin中使用Retrofit2+SimpleXML从API获取XML数据并将其映射到Kotlin模型对象。但是,我从SimpleXML收到了如下错误消息。org.simpleframework.xml.core.MethodException:Annotation@org.simpleframework.xml.Element(data=false,name=,required=true,type=void)mustmarkasetorgetmethod这是获取的XML数据SuccessXXXXXXXXXXXXXXXXXXXX4294967295Kotlin模型对象在下

android - 房间持久性 : Error:Entities and Pojos must have a usable public constructor

我正在将一个项目转换为Kotlin,并且我正在尝试使我的模型(也是我的实体)成为一个数据类我打算使用Moshi转换来自API的JSON响应@Entity(tableName="movies")dataclassMovieKt(@PrimaryKeyvarid:Int,vartitle:String,varoverview:String,varposter_path:String,varbackdrop_path:String,varrelease_date:String,varvote_average:Double,varisFavorite:Int)由于以下错误,我无法构建应用程序E

android - Google 应用内计费,升级到 Android L Dev Preview 后出现 IllegalArgumentException : Service Intent must be explicit,

在我升级到AndroidLDevPreview之前,我的应用内结算代码运行良好。现在,当我的应用程序启动时出现此错误。有谁知道导致此问题的L发生了什么变化,或者我应该如何更改我的代码来解决这个问题?android{compileSdkVersion'android-L'buildToolsVersion'20'defaultConfig{minSdkVersion13targetSdkVersion'L'......compile'com.google.android.gms:play-services:5.+'compile'com.android.support:support-v

android - ADT 22.3 (android 4.4) - 出现错误 "After scene creation, #init() must be called"

安装支持Android4.4(KitKat)的新ADT(22.3.0.v201310242005-887826)后,我不断收到如下所示的错误:Aninternalerrorhasoccurred在错误列表中,我看到多个“RenderPreview”项,当我单击其中任何一项时,我看到:Aninternalerrorhasoccurred.Afterscenecreation,#init()mustbecalled在另一台计算机上测试新的ADT时,我看不到该错误出现在那里。这很奇怪。为什么我会收到这些错误,我可以做些什么来修复它? 最佳答案