Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rtmigo/errno

Defines system error code constants for the OSs running the Dart platform
https://github.com/rtmigo/errno

android dart dart-library darwin errno error-codes error-success errors exceptions flutter header-files headers ios kernel linux macos os posix windows winerror

Last synced: 9 days ago
JSON representation

Defines system error code constants for the OSs running the Dart platform

Awesome Lists containing this project

README

        

[![Pub Package](https://img.shields.io/pub/v/errno.svg)](https://pub.dev/packages/errno)
[![Actions Status](https://github.com/rtmigo/errno/workflows/unittest/badge.svg?branch=master)](https://github.com/rtmigo/errno/actions)

# [errno](https://github.com/rtmigo/errno)

Defines **system error code** constants for the OSs running the Dart platform.

With these numeric codes, the
[OSError.errorCode](https://api.dart.dev/stable/dart-io/OSError/errorCode.html)
property usually specifies the problem that occurred.

| OS | Class |
|----------------|-----------------|
| Android, Linux | `LinuxErrors` |
| iOS, macOS | `DarwinErrors` |
| Windows | `WindowsErrors` |

## Example

``` dart
import 'dart:io';

import 'package:errno/errno.dart';

void main() {

try {

var lst = Directory("My Documents").listSync();
print(lst);

} on FileSystemException catch (exc) {

if (exc.osError?.errorCode == WindowsErrors.pathNotFound) {

print("The directory does not exist.");

} else {
rethrow;
}
}
}
```