-
Notifications
You must be signed in to change notification settings - Fork 23
Handle Unknown errors in Erlang #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
2de2585
228f5c9
919bc92
3499105
7b77903
44836a5
7965381
dfb0527
3d4a619
8f44c91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,8 @@ pub type FileError { | |
| /// Inappropriate file type or format. Usually caused by trying to set the | ||
| /// "sticky bit" on a regular file (not a directory). | ||
| Eftype | ||
| /// Host is down. | ||
| Ehostdown | ||
|
||
| /// Interrupted system call. | ||
| Eintr | ||
| /// Invalid argument. | ||
|
|
@@ -170,6 +172,7 @@ pub fn describe_error(error: FileError) -> String { | |
| Enosr -> "No STREAM resources" | ||
| Enostr -> "Not a STREAM" | ||
| Eopnotsupp -> "Operation not supported on socket" | ||
| Ehostdown -> "Host is down" | ||
| NotUtf8 -> "File not UTF-8 encoded" | ||
| Unknown(inner) -> "Unknown error: " <> inner | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ | |
| orelse Error =:= efault | ||
| orelse Error =:= efbig | ||
| orelse Error =:= eftype | ||
| orelse Error =:= ehostdown | ||
| orelse Error =:= eintr | ||
| orelse Error =:= einval | ||
| orelse Error =:= eio | ||
|
|
@@ -91,9 +92,14 @@ posix_result(Result) -> | |
| {ok, Value} -> | ||
| {ok, Value}; | ||
| {error, Reason} when ?is_posix_error(Reason) -> | ||
| {error, Reason} | ||
| {error, Reason}; | ||
| {error, Reason} -> | ||
| {error, {unknown, error_reason_to_binary(Reason)}} | ||
| end. | ||
|
|
||
| error_reason_to_binary(Reason) -> | ||
| unicode:characters_to_binary(io_lib:format("~tp", [Reason])). | ||
|
||
|
|
||
| %% Read the binary contents of a file | ||
| read_bits(Filename) -> | ||
| posix_result(file:read_file(Filename)). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { createDirectory } from "./simplifile_js.mjs"; | ||
|
|
||
| export function createDirectoryWithBadArg(arg) { | ||
| return createDirectory(arg); | ||
| } | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a docs update that doesn't affect the version number, so I think it shouldn't be in the changelog.