some errors about rabbitmq-erlang-client - rabbitmq

I'm trying to use rabbitmq-erlang-client, and confused about errors throwed by program.
I fllowed system_SUITE:queue_unbind/1 But errors are throwed when setting Exchange and Queue :
%% code
amqp_channel:call(Channel, #'exchange.declare'{exchange = X}),
amqp_channel:call(Channel, #'queue.declare'{queue = Q}),
%% it throw me same errors again and again:
** Last message in was setup_exchange_queue
** When Server state == {state,
{amqp_params_network,<<"username">>,<<"password">>,
<<"/">>,"192.168.1.173",5672,0,0,10,infinity,
none,
[#Fun<amqp_auth_mechanisms.plain.3>,
#Fun<amqp_auth_mechanisms.amqplain.3>],
[],[]},
<0.74.0>,<0.83.0>,<<"amq.direct">>,<<"queue">>,
<<"my_queue">>,undefined,undefined}
** Reason for termination ==
** {{noproc,{gen_server,call,[<0.83.0>,{close,200,<<"Goodbye">>},infinity]}},
[{gen_server,call,3,[{file,"gen_server.erl"},{line,212}]},
{mrbq,terminate,2,[{file,"src/mrbq.erl"},{line,244}]},
{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,643}]},
{gen_server,terminate,7,[{file,"gen_server.erl"},{line,809}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
** exception exit: {noproc,
{gen_server,call,
[<0.83.0>,{close,200,<<"Goodbye">>},infinity]}}
code review amqp_channel.erl
%% call
call/2 -> gen_server:call/2
handle_call/3 -> handle_method_to_server/6
goto line 573, then line 888 ,and {noreply, State} returned for call as a result!!
What's wrong with above steps?
What should do to make it OK?
I have had tried cast/2,and no errors occur. But this is not what I need.

Related

How can I know the command used? - Discord.py

I am trying to make a errorhandling for my Discord.py, how do I know what command was used for the error to pop up?
#bot.event
async def on_command_error(ctx, error):
print("error: ",error)
if search("not found", str(error)):
c_f = random.choice([f"`{command used}` was not found, silly.", "Ehm.. Since when do we have `{command used}`?", "I don't know what `{command used}` is?"])
embed=discord.Embed(title=c_f, description=f"Please use existing commands. {ctx.author.mention}", color=error_color)
embed.timestamp = datetime.utcnow()
embed.set_footer(text=bot_name, icon_url=icon_uri)
await ctx.send(embed=embed)
elif search("cooldown", str(error)):
c_d = random.choice(["Did you drink energy drinks!?", "Why are you stressing, buddy.", "Duhh, wait, you're on cooldown!"])
second_remain = round(error.retry_after, 1)
embed=discord.Embed(title=c_d, description=f"Try again after {second_remain}s. {ctx.author.mention}", color=error_color)
embed.timestamp = datetime.utcnow()
embed.set_footer(text=bot_name, icon_url=icon_uri)
await ctx.send(embed=embed)
else:
raise error
Any attribute I can use?
You can use ctx.command
#bot.event
async def on_command_error(ctx, exception):
error = getattr(exception, "original", exception)
if hasattr(ctx.command, "on_error"): # If a command has it's own handler
return
elif isinstance(error, CommandNotFound):
return
if isinstance(error, discord.CommandInvokeError):
print(ctx.command)
Your solution is to add them to the command specifically, this also means it can help diagnose an issue with a command more exact.
You can also add any error events to the specific listener, just like how you done it for all commands, instead add them individually.
#bot.command()
async def command_name(ctx):
# ...
#command_name.error
async def command_name_error(ctx, error):
if isinstance(error, commands.CommandInvokeError):
await ctx.send("An error from this command" + error)
With #command_name.error put your command name before the .error, then this makes an error listener for that command, if it produces an error.

How to make if else checkbox enabled/disabled in sql query and asp.net?

I want to make my checkbox is enabled and disable when user login from my data
My syntaks in asp.net:
if (Session["Berhasil"] != null)
{
Label1.Visible = true;
Label1.Text = "Berhasil..";
if(Label1 = "select * from cs100020 where countno=2 and status=3");
{
cbxinven.Enabled=true
cbxfinadmin.Enabled=true
cbxkaskecil.Enabled=true
cbxemail.Enabled=false
cbxsap.Enabled=false
cbxpc.Enabled=false
cbxuserad.Enabled=false
}
else (Label1="select * from cs100020 where countno=3 and status=3);
{
cbxinven.Enabled=false
cbxfinadmin.Enabled=false
cbxkaskecil.Enabled=false
cbxemail.Enabled=true
cbxsap.Enabled=true
cbxpc.Enabled=true
cbxuserad.Enabled=true
}
}
and i got error :
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1010: Newline in constant
Source Error:
Line 137: cbxuserad.Enabled=false
Line 138: }
Line 139: else (Label1="select * from cs100020 where countno=3 and status=3);
Line 140: {
Line 141: cbxinven.Enabled=false
Source File: d:\Sharing\Budiman\IAPHRM BACKUP 08022019\IapHRM_180119_Backup\ViewCS.aspx.cs Line: 139
Show Detailed Compiler Output:
Show Complete Compilation Source:
The closing double quote on the SQL statement for the ELSE branch (i.e. else (Label1 = .... line) is missing.

Strange behavior, Erlang ssl:connect work only in first call

I have small web server on my host. And I try to connect them with https.
I have next test function
request2(Host)->
ssl:start(),
{ok, Socket} = ssl:connect(Host, 8013, [{active, false},{certfile,"/home/user/sipo.pem"}], 10000),
ssl:close(Socket).
and in repl we have next:
(emacs#host-15)112> ssl:start().
ok
(emacs#host-15)113> test:request2("192.168.31.57").
ok
(emacs#host-15)114> test:request2("192.168.31.57").
** exception error: no match of right hand side value {error,closed}
in function test:request2/1 (/home/user/src/test.erl, line 78)
(emacs#host-15)117> ssl:stop().
ok
(emacs#host-15)118> ssl:start().
ok
(emacs#host-15)119> test:request2("192.168.31.57").
ok
(emacs#host-15)120> test:request2("192.168.31.57").
** exception error: no match of right hand side value {error,closed}
in function test:request2/1 (/home/user/src/test.erl, line 78)
(emacs#host-15)121>
Why the call request2 is work fine only once and afrer that I have error {error,closed}. Whot is happend?

compiler error using tryRecv

I have the following Nim program:
import threadpool
var channel: TChannel[string]
proc consumer(channel: TChannel[string]) =
let (flag,msg) = tryRecv(channel)
if flag:
echo msg
channel.open()
spawn consumer(channel)
channel.send("hello")
channel.close()
sync()
When I try to compile it, it gives me this error message:
testchannels.nim(6, 27) Error: type mismatch: got (TChannel[system.string])
but expected one of:
system.tryRecv(c: var TChannel[tryRecv.TMsg])
I don't understand what the error message is trying to tell me...
Ahh, I think I got it now!
The important part of the error message was the var in system.tryRecv(c: var TChannel[tryRecv.TMsg]): tryRecv expects the channel variable to be mutable, which it wasn't in the above code.
The solution is to remove the parameter from the consume proc:
import threadpool
var channel: TChannel[string]
proc consumer() {.gcsafe.} =
if peek[string](channel) != -1:
echo recv(channel)
channel.open()
spawn consumer()
channel.send("hello")
channel.close()
sync()

TCL, get full error message in catch command

#!/usr/bin/tclsh
proc test {} {
aaa
}
test
When I run this script I get error message:
invalid command name "aaa"
while executing
"aaa"
(procedure "test" line 2)
invoked from within
"test"
(file "./a.tcl" line 7)
If I run test command in catch I get only first line of error message.
#!/usr/bin/tclsh
proc test {} {
aaa
}
catch test msg
puts $msg
This prints:
invalid command name "aaa"
Is it possible to get full error message (file, line, procedure) in catch command? My program has many files and by getting just one line of error message it is difficult to find from where is it.
The short answer is to look at the value of errorInfo which will contain the stack trace.
The more complete answer is to look at the catch and the return manual pages and make use of the -optionsVarName parameter to the catch statement to collect the more detailed information provided. The return manual page gives some information on using this. But a rough example from an interactive session:
% proc a {} { catch {funky} err detail; return $detail }
% a
-code 1 -level 0 -errorstack {INNER {invokeStk1 funky} CALL a} -errorcode NONE -errorinfo {invalid command name "funky"
while executing
"funky"} -errorline 1
%
The detail variable is a dictionary, so use dict get $detail -errorinfo to get that particular item.