Skip to content

Commit c00a3a5

Browse files
committed
catch errors
1 parent 66b00f8 commit c00a3a5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/patch/cst.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,15 @@ patch(io::IO, src::SourceFile, p::Patch) = patch(io, src, replacement(src, p))
107107
patch(src::SourceFile, p) = sprint(patch, src, p)
108108

109109
function patch!(src::SourceFile, p)
110+
s = read(src.path)
110111
open(src.path, "w") do io
111-
patch(io, src, p)
112+
try
113+
patch(io, src, p)
114+
catch _
115+
seek(io, 0)
116+
write(io, s)
117+
rethrow()
118+
end
112119
end
113120
end
114121

@@ -123,6 +130,7 @@ function sourcemap(f, path::AbstractString)
123130
s = SourceFile(path)
124131
ex = striplines(f(s.ast))
125132
patch!(s, diff(s.ast, ex))
133+
return
126134
end
127135

128136
function sourcemap_dir(f, path)

0 commit comments

Comments
 (0)