Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Catch all exceptions in playframework and friendly error page in production

You can do this by extending the GlobalSettings trait, and overriding the onError method.

import play.api.GlobalSettings
import play.api._
import play.api.mvc._
import play.api.mvc.Results._
import scala.concurrent.Future

object Global extends GlobalSettings {
    override def onError(request: RequestHeader,
e: Throwable) = {

Note that this Global object must be in the default package in order to work. onError is called whenever there is an unhandled exception within an Action. There, you'll have access to the original Request, and the exception that was thrown. Here, I'm just logging the exception message and returning a Result with some error view.

Categories : Scala

Related to : Catch all exceptions in playframework and friendly error page in production
Python how to exclude exceptions from "catch all"
Your problem seems to be that you are wrapping too much code in your try block. What about this?: try: result = call_external_service() except Exception: # unexpected exceptions from calling external service do_some_logging() if result != expected: raise MyException()

Categories : Python
Do-while, try-catch loop error
Move reading cadena into the try block int z = 0; do { try { cadena = LeerTeclado.nextLine(); // <-- re-read if ("salir".equalsIgnoreCase(cadena)) { // <-- you might test once. System.exit(0); } // if ("Salir".equals(cadena)) { // System.exit(0); // } z = Integer.valueOf(cadena); // <-- or this loops forever.

Categories : Java
Index was outside the bounds of the array. CATCH an error
You have this line: PartNumber = TextBox1.Text; Immediately followed by this: if (PartNumber == TextBox1.Text) Which will always be true given that you just set that value to PartNumber. Therefore, you'll never enter your else statement. What you should do is check to see if PQ has anything in it before using it: if (PQ.Parts.Length>0) { PriceSum = String.Format(PQ.Parts[0].Cost.To

Categories : C#
Any idea why my 'register_shutdown_function' wouldn't catch a 'require' error?
If the INI configuration options 'display_errors' or 'display_startup_errors' are set to 1 ( or true ), the errors will still be displayed, regardless of the presence of a method to handle the errors. In this case, my workaround came out something like this: Edit To Add for Globals // config.php // Name of your error callback method $ErrorCallback = "HandleRuntimeError"; // Name of your excepti

Categories : PHP
How can i catch error in wso2esb, when i send message to web service?
In your outSequence, when you receive a response from your REST service, you can test HTTP Status code with swith or filter mediator, sample : <filter source="$axis2:HTTP_SC" regex="500"> <then> ... </then> <else> ... </else> </filter>

Categories : Misc
Recently Add
Reverse list of n elements
scalac: Error: object CharRef in intelliJ 14
Scala - trouble with type inference in lambda expression
Exception on spark test
How can I emulate Haskell's typeclasses in Scala?
Slick: CRUD extension: How to encapsulate implicit mapping:BaseColumnType[T]
Can't find Traverse for sequencing Seq[ValidationNel[String, MyCaseClass]] => ValidationNel[String, Seq[MyCaseClass]]
Tail recursion: internal "loop" function or default values for accumulators
Scala - Add element:MyType to Array = option[MyType] expected
Scala, Composing Function with two values
Using dependent type to generate compile error
How to match all words in a sentence with scala combinators?
Parser Alternative Operator | Fails
ScalaTest assertion mismatch due to Physical Address
Scala implicit parameter and japanese smiley 'foldLeft'
Is it possible to user reduceByKey((x, y, z) => ...)?
How to implement security Authorization using scala and play?
SSO login using scala script
Sum elements based on a predicate
Keep track of completed Futures
API Observable with dynamic caching Remotely closed in gatling
Scala permutations using two lists
Is Scala Either really a Monad
Spark: Use of distinct
Identifying two type wildcards as identical
how to package spark scala application
Pattern Match on Scala `class`
Type mismatch when using higher-kinded types
Scala List match last element
© Copyright 2017 Publishing Limited. All rights reserved.