Skip to content

Commit d047e1f

Browse files
committed
add err handling to example
1 parent a3ddc1d commit d047e1f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
program example_get_file_size
2+
use, intrinsic :: iso_fortran_env, only: int64
23
use stdlib_system, only: get_file_size
4+
use stdlib_error, only: state_type
35
implicit none
6+
7+
type(state_type) :: err
8+
integer(int64) :: size
49

5-
character(*), parameter :: path = "src"
10+
character(*), parameter :: path = "path/to/check"
11+
12+
size = get_file_size(path, err)
613

7-
print *, get_file_size(path)
14+
if (err%ok()) then
15+
print *, "Size in bytes = ", size
16+
else
17+
print *, "Error!: ", err%print()
18+
end if
819

920
end program example_get_file_size
1021

0 commit comments

Comments
 (0)