File: example_fs_error.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (23 lines) | stat: -rw-r--r-- 834 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
! Demonstrate usage of `FS_ERROR`, `FS_ERROR_CODE`
program example_fs_error
    use stdlib_system, only: FS_ERROR, FS_ERROR_CODE
    use stdlib_error, only: state_type, STDLIB_FS_ERROR
    implicit none

    type(state_type) :: err0, err1

    err0 = FS_ERROR("Could not create directory", "`temp.dir`", "- Already exists")

    if (err0%state == STDLIB_FS_ERROR) then
        ! Error encountered: Filesystem Error: Could not create directory `temp.dir` - Already exists
        print *, err0%print() 
    end if

    err1 = FS_ERROR_CODE(1, "Could not create directory", "`temp.dir`", "- Already exists")

    if (err1%state == STDLIB_FS_ERROR) then
        ! Error encountered: Filesystem Error: code - 1, Could not create directory `temp.dir` - Already exists
        print *, err1%print()
    end if

end program example_fs_error