Hi,

Just some simple java code to learn some basics of materialized values.
There is an intentional error in the code snippet  in the String.format 
that uses an invalid %l which actually throws an exception but nothing gets 
printed in the console.
What exactly is happening and how does one handle a scenarios like this to 
actually see/debug the exception?
​
​

public class Sample {

    public static void main(String[] args) throws IOException{

        ActorSystem system = ActorSystem.create("system");
        ActorMaterializer mat = ActorMaterializer.create(system);

        Source<ByteString, CompletionStage<IOResult>> source = 
FileIO.fromFile(new File("blah.txt"));

        Sink<ByteString, CompletionStage<IOResult>> sink = FileIO.toFile(new 
File("c:\\temp\\blah.txt.copy"));

        RunnableGraph<CompletionStage<IOResult>>  runnableGraph = 
source.to(sink);

        //RunnableGraph<CompletionStage<IOResult>> runnableGraph1 = 
source.toMat(sink, Keep.left());

        //RunnableGraph<CompletionStage<IOResult>> runnableGraph2 = 
source.toMat(sink, Keep.right());

        //RunnableGraph<Pair<CompletionStage<IOResult>, 
CompletionStage<IOResult>>> pairRunnableGraph = source.toMat(sink, Keep.both());

        final CompletionStage<IOResult> cs = runnableGraph.run(mat).handle((x, 
t) -> {
            if(t!=null){
                System.out.println("Error: " + t);
            }
            if (x!=null){
                String s = String.format("%s , %l bytes 
read",x.status(),x.count());
                System.out.println(s);
            }
            return null;
        });

​
-chhil

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to