getting an error while using JDA in android - discord-jda

Basically i'm planing to make a music bot android application,but i'm getting the following error.
Here is the error i'm getting
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jdabot, PID: 18944
java.lang.ExceptionInInitializerError
at net.dv8tion.jda.internal.utils.Checks.notNull(Checks.java:68)
at net.dv8tion.jda.api.requests.GatewayIntent.getRaw(GatewayIntent.java:255)
at net.dv8tion.jda.api.requests.GatewayIntent.<clinit>(GatewayIntent.java:169)
at net.dv8tion.jda.api.JDABuilder.<clinit>(JDABuilder.java:58)
at net.dv8tion.jda.api.JDABuilder.createLight(JDABuilder.java:241)
at com.example.jdabot.MainActivity.<init>(MainActivity.java:21)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)"
I have no idea why am i getting this error can any one help me out.
My code is below
JDA jda;
{
try {
jda = JDABuilder.createLight("token").build();
} catch (LoginException e) {
e.printStackTrace();
}
}
no matter whatever i try the output result is same.

Related

Anchor,Solana -> failed to send transaction: Transaction simulation failed Custom Error 0x0

I am trying to build a simple coin flip game in solana.
Full code here
I get this error:
Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0
I followed some tutorials on how to use PDA's but couldn't find a report/workaround to an error as such.
Tests are running on localhost
I did some research and it might be that the account was already initialized ( maybe, no idea)
the part that is giving the error:
try {
await program.rpc.initialize(bump,
{
accounts: {
treasury: treasuryPda, // publickey for our new account
user: provider.wallet.publicKey,
systemProgram: SystemProgram.programId // just for Anchor reference
},
});
} catch (error) {
console.log("Transaction error: ", error);
console.log("blabla:", error.toString());
}

Error Handling / Throw error in Strapi 4.0

in Strapi 4.0, i want to validate the input before saving. So i created lifecycles.js file as per the documentation and added the code:
module.exports = {
beforeCreate(event) {
//validation login here;
if (!valid) {
throw strapi.errors.badRequest('Invalid Entry');
}
},
}
How ever throw strapi.errors.badRequest('Invalid Entry'); is giving an error :
Cannot read property 'badRequest' of undefined
My guess is the Strapi v4 changed it from version 3. I looked everywhere but couldn't find a solution.
Any idea on how to handle error in lifecycles.js?
I had a similar situation with a forbidden error. I got to do it importing a class from #strapi/utils/lib/errors.js
const { ForbiddenError } = require("#strapi/utils").errors;
...
if (!authorized) {
throw new ForbiddenError(errorMessage);
}
You can show the list of errors based on your requirement
const { ValidationError } = require("#strapi/utils").errors;
...
if (formValidationError) {
throw new ForbiddenError("Fill the form");
}
Strapi comes with a lot of error response functions here are they
HttpError,
ApplicationError,
ValidationError,
YupValidationError,
PaginationError,
NotFoundError,
ForbiddenError,
PayloadTooLargeError,
UnauthorizedError,
PolicyError,

Realm throw catch swift 2.0

does anyone know the syntax for the try-catch of the following realm function is?
realm.write() {
realm.add(whatever)
}
I'm getting the following error:
call can throw but it is not marked with 'try' and the error is not
handled
From what I imagine realm.write() can throw an exception. In Swift 2 you handle exceptions with do/catch and try.
I suspect that you should do something like this:
do {
try realm.write() {
realm.add(whatever)
}
} catch {
print("Something went wrong!")
}
If realm.write() throws an exception, print statement will be invoked immediately.
It looks like an NSError gets thrown. See the Swift 2.0 source
Adding on to #tgebarowski's answer:
do {
try self.realm.write {
realm.add(whatever)
}
} catch let error as NSError {
print("Something went wrong!")
// use the error object such as error.localizedDescription
}
You can also try
try! realm.write {
realm.add(whatever)
}

Gets FormatException when trying to query data to Parse.com in Unity

I'm using Parse plugin 1.5.5 for Unity 5.1.3 in order to communicate with Parse.com in Unity. I'm getting FormatException when trying to connect to Parse when there is no internet connection with following code. I was wondering if this is a bug of Parse plugin or anything I did wrong.
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Data");
query.FirstAsync().ContinueWith (task =>
{
if (task.IsCanceled)
{
Debug.Log ("parse canceled");
}
else if(task.IsFaulted)
{
Debug.Log ("parse error");
}
else
{
Debug.Log ("parse retrieved");
}
});
Error code is following.
FormatException: Input string was not in the correct format
System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono- runtime-and-classlibs/build/mcs/class/corlib/System/Int32.cs:629)
Parse.PlatformHooks+HttpRequestUnity.getStatusCode (UnityEngine.WWW www)
Parse.PlatformHooks+HttpRequestUnity+<>c__DisplayClass40+<>c__DisplayClass46.<ExecuteAsync>b__3a (UnityEngine.WWW www)
Parse.PlatformHooks+<>c__DisplayClass24.<RegisterNetworkRequest>b__23 ()
Parse.PlatformHooks+<RunDispatcher>d__2e.MoveNext ()
UnityEngine.Debug:LogException(Exception)
Parse.<RunDispatcher>d__2e:MoveNext()
Thank you,

Error processing GroovyPageView: getOutputStream() has already been called for this response

I have an action that writes directly to the output stream. Sometimes I get the following to errors:
Error processing GroovyPageView: getOutputStream() has already been called for this response
Caused by getOutputStream() has already been called for this response
and this one:
Executing action [getImage] of controller [buddyis.ItemController] caused exception: Runtime error executing action
Caused by Broken pipe
How can I solve these problems? The action I use is listed below.
NOTE: I use Tomcat 7.0.42, if this is important!
def getImage() {
byte [] imageByteArray = // some image bytes
response.setHeader 'Content-disposition', "attachment; filename=\"${imageName}${imageExtension}\""
response.setContentType("image/pjpeg; charset=UTF-8")
response.contentLength = imageByteArray.size()
response.outputStream.write(imageByteArray)
response.outputStream.flush()
response.outputStream.close()
return
}
I don't know why you are getting that error, however here is what I do that works everytime.
I don't call .flush() or .close()
response.setContentType("application/octet-stream")
response.setHeader("Content-disposition", "filename=\"${name}\"")
response.setContentLength(imageByteArray.size())
response.outputStream << imageByteArray
Using the above it was working fine, until I found out a user can cancel a download, which caused an exception. This is the full code I use instead of response.outputStream << imageByteArray:
def outputStream = null
try {
outputStream = response.outputStream
outputStream << imageByteArray
} catch (IOException e){
log.debug('Canceled download?', e)
} finally {
if (outputStream != null){
try {
outputStream.close()
} catch (IOException e) {
log.debug('Exception on close', e)
}
}
}
I had this issue whilst running grails 2.5 on tomcat:7.0.55.3 and with the java-melody grails plugin installed. After uninstalling java-melody it worked just fine

Resources