# Io error handling examples?

**URL:** https://discourse.julialang.org/t/io-error-handling-examples/92009
**Category:** New to Julia
**Tags:** question, error, io
**Created:** [December 22, 2022, 3:42pm UTC](https://discourse.julialang.org/t/io-error-handling-examples/92009 "2022-12-22T15:42:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)
#### Post date: [December 22, 2022, 3:42pm UTC](https://discourse.julialang.org/t/io-error-handling-examples/92009/1 "2022-12-22T15:42:58Z")

</div>

Hi there  
just had an event that highlit how being lazy will get you every time. I have working code BUT no real error handling in the IO component. I was wondering if there is a example or example(s) anywhere which show the julia canonical way to handle io events. I don’t want to reinvent the wheel if there is a Pkg or a example that I can work with.

In my case I had a problem which **got resolved** BUT because I was lazy the code just crashed. I know about try/catch and I have added logging to my code.

```julia
ERROR: [ Info: reader exiting
LoadError: IOError: write: broken pipe (EPIPE)
Stacktrace:
 [1] uv_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
   @ Base ./stream.jl:1064
 [2] unsafe_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)

```

---

<div class="post-metadata">

### Author: ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)
#### Post date: [December 22, 2022, 5:44pm UTC](https://discourse.julialang.org/t/io-error-handling-examples/92009/2 "2022-12-22T17:44:19Z")

</div>

@bkamins to the rescue once again! [THE cookbook on error handling](https://subscription.packtpub.com/book/application-development/9781788998369/5/ch05lvl1sec65/handling-exceptions-in-julia) lashings of excellent examples for everything in here. Can’t understand why I didn’t think about it before. AH laziness and stupidity…  
have an EXCELLENT holidays all.
