Saturday, 19 March 2016

Julia: logging information, warning and error messages

Following functions are used to log information, warning, error messages.


Function
Description
info(msg)
Display an information message, don’t interrupt program execution.
warn(msg)
Display a warning message, don’t interrupt program execution
error(msg)
Display error message, interrupt program execution

julia> function process_info(a)
           if(a<0)
               error("Invalid Domain")
           elseif(a>100)
               warn("Index out of bounds")
           else
               info("Processing data")
           end 
           println("\n Processing done")
       end
process_info (generic function with 2 methods)

julia> process_info(-1)
ERROR: Invalid Domain
 in process_info at none:3

julia> process_info(1)
INFO: Processing data

 Processing done

julia> process_info(101)
WARNING: Index out of bounds

 Processing done




Previous                                                 Next                                                 Home

No comments:

Post a Comment