I know how to raise an exception and how to handle it , but suppose I have this method:
method1:arg
AssertionFailure signal:'rescue error comment'.
I want to catch this exception and create new Assertion failure exception with another format.However I need to get that message ("rescue error comment") and use it in my new exception.. and this is where I don't know what to do...
so how do I get that message before the handling the exeption by using
on: AssertionFailure do:
Either use
on: AssertionFailure do: [ :e | NewAssertionFailure signal: e messageText ]
or define method as
method1:arg
NewAssertionFailure signal: 'rescue error comment'
Related
I am new to WebRTC and triyng to create my first app. I have found this article https://www.tutorialspoint.com/webrtc/webrtc_quick_guide.htm and did as it was said there. The resulted app works fine if I test it in the Chrome. But when I try to test this app in 2 browser (Chrome and Mozilla) it gives me this error:
Uncaught (in promise) DOMException: Failed to execute
'setRemoteDescription' on 'RTCPeerConnection': Session error code:
ERROR_CONTENT. Session error description: Data channel type mismatch.
Expected RTP, got SCTP..
This happens when I send an offer from Mozilla client and Chrome client tries to give an answer to this offer in this part of code:
myConnection.setRemoteDescription(new RTCSessionDescription(offer));
myConnection.createAnswer(function (answer) {
myConnection.setLocalDescription(answer);
send({
type: "answer",
answer: answer
});
}, function (error) {
alert("oops...error"); //<-- this alert fires all the time
});
I have googled this and all I have found is set new RTCPeerConnection(configuration, { optional: [{RtpDataChannels: false}] }) but if I do so then when I try to send a message it says that dataChannel.readyState is not openned.
What do I do wrong? Any help appriciated!
Thanks!
Remove optional: [{RtpDataChannels: true}] and then wait for the datachannel.onopen event to fire before attempting to send messages.
This question is to validate the custom error handling implementation here or is there a better workaround possible?
Is there any other best possible way that you could suggest?
I am using Suave with Asp.Net core and kestrel server in F# to build microservices.
I want to add http status code and error message for specific server side errors for the client using the microservices' restful api's.
I have the following code.
Startup.fs code ==>
member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment, loggerFactory: ILoggerFactory) =
app.UseSuaveErrorHandler(ConfigApp.ErrHandler) |> ignore
<TODO>
type ConfigApp () =
static member ErrHandler (ex:exn) (message:string) (httpContext:HttpContext) =
let logRepository =
log4net.LogManager.GetRepository(Assembly.GetEntryAssembly())
log4net.Config.XmlConfigurator.Configure(logRepository,
FileInfo("log4net.config")) |> ignore
FloLogger.debug "Exception= %s" ex.Message
FloLogger.debug "Exception= %s" ex.StackTrace
match ex.Message with
| x -> INTERNAL_ERROR ("Custom Error Handler: " + ex.Message) httpContext
InnerMethod fs file code excerpt
let fnGetManufacturerInfoByIdDAL (manufacturerID:string) =
try
FloLogger.debug "Inside fnGetManufacturerInfoByIdDAL method"
printfn "Inside fnGetManufacturerInfoByIdDAL method - %s" manufacturerID
use session = objSettings.OpenSession()
// Querying database
let manufacturerList = session.Load<Manufacturer>((manufacturerID))
manufacturerList.Etag <- session.Advanced.GetEtagFor(manufacturerList);
// disposing the opened db session
session.Dispose()
manufacturerList
with
| smilie Exception as ex -> FloLogger.debug "%s" ex.Message
FloLogger.debug "%s" ex.StackTrace
let strException = "{\"error occurrred...\":\"error..\"}" + ex.Message
failwith strException
So the exception raised by the code in the inner method file get's handled by the Suave error handler which sends the http status code and the exception message in the response as shown in the screenshot attached.
But the server errors available with Suave are very few and from them Internal_Error suits the code errors the best.
Is there any way to make the function Invoke-Sqlcmd2 not terminate the rest of the script on failure?
I want the rest of my script to continue to run even if this command fails.
I've dug around the code and my thought is it has something to do with the -ErrorAction parameter.
Below is line 488 of the script:
Catch # For other exception
{
Write-Verbose "Capture Other Error"
$Err = $_
if ($PSBoundParameters.Verbose) {Write-Verbose "Other Error: $Err"}
switch ($ErrorActionPreference.tostring())
{
{'SilentlyContinue','Ignore' -contains $_} {}
'Stop' { Throw $Err} # Removing this line doesn't work
'Continue' { Throw $Err}
Default { Throw $Err}
}
}
Any ideas on how to get this command to 'non-terminate'?
Solution:
Thanks for the info. I ended up wrapping the error handling section of invoke-sqlcmd2 in a try-catch trap.
Putting the Invoke-SQLCMD2 inside a try catch block and maybe log the error thrown.
That way you will handle the error and the script will go on.
I need help with the above-mentioned error. My project is using AsyncDisplayKit and I am getting the error above in the _ASDisplayLayer.mm file line 104 in the method
- (void)setNeedsLayout
{
ASDisplayNodeAssertMainThread();//line 104 where error is occuring
[super setNeedsLayout];
}
I don't know how to solve this problem as I am new to the library and I am just rerunning a previous developer's work. Full error stack is:
* Assertion failure in -[_ASDisplayLayer setNeedsLayout], /Users/.../Desktop/.../Pods/AsyncDisplayKit/AsyncDisplayKit/Details/_ASDisplayLayer.mm:104
2016-03-16 00:17:08.951 DanceRockIt[408:168719] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ''
*** First throw call stack:
(0x252fa2eb 0x24ac6dff 0x252fa1c1 0x25ad0d3b 0x27f519 0x2755f93b 0x2755f3d9 0x2756240b 0x2758f1f5 0x2949954b 0x297c4525 0x294b3a69 0x294f9e2d 0x2956c68d 0x2956d473 0x2956b935 0x345515 0x345259 0x12abcd 0x106ccbf 0x10775c3 0x106fefb 0x1079017 0x1078909 0x25030e0d 0x250309fc)
libc++abi.dylib: terminating with uncaught exception of type NSException
Something call your setNeedsLayout code from background thread. You must find this place and move to GUI Thread (aka main thread).
for example:
dispatch_async(dispatch_get_main_queue(), ^{
[self.titleTextNode setNeedLayout];
});
I added the following like to the backtrace_silencers initializer file:
Rails.backtrace_cleaner.add_filter { |line| line.gsub(Rails.root, '') }
I get the following error message in my rails server when an exception occurs:
Error during failsafe response: wrong argument type Pathname (expected
Regexp) .../config/initializers/backtrace_silencers.rb:2:in `gsub'
Which is odd b/c gsub is used as an example here:
http://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html
Any idea what's going on?
Try
Rails.backtrace_cleaner.add_filter { |line| line.gsub(Rails.root.to_s, '') }