{"id":25234148,"url":"https://github.com/elias8/networkx","last_synced_at":"2025-04-05T17:15:06.807Z","repository":{"id":115662363,"uuid":"580885799","full_name":"elias8/networkx","owner":"elias8","description":"Custom network error types for easy error handling.","archived":false,"fork":false,"pushed_at":"2023-05-19T20:04:49.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T13:59:07.064Z","etag":null,"topics":["dart","dio","error-handling","http","networking"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/networkx","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elias8.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-21T17:46:07.000Z","updated_at":"2024-09-05T04:50:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"74c7c14e-6047-484e-8cc5-3d8dd7411bb7","html_url":"https://github.com/elias8/networkx","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elias8%2Fnetworkx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elias8%2Fnetworkx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elias8%2Fnetworkx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elias8%2Fnetworkx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elias8","download_url":"https://codeload.github.com/elias8/networkx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369948,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","dio","error-handling","http","networking"],"created_at":"2025-02-11T13:58:44.868Z","updated_at":"2025-04-05T17:15:06.795Z","avatar_url":"https://github.com/elias8.png","language":"Dart","readme":"Custom network error types for easy error handling.\n\n## Getting started\n\nInstall the latest version from pub.dev.\n\n```yaml\ndependencies:\n  networkx: ^0.2.1\n```\n\n## Usage\n\n```dart\nimport 'package:networkx/networkx.dart';\n\nvoid main() {\n  const networkError = NetworkError.api(ApiValidationError.emailAlreadyExists);\n\n  // `maybeWhen`\n  networkError.maybeWhen(\n    api: (error) {\n      if (error == ApiValidationError.emailAlreadyExists) {\n        print('Email already exists.');\n      } else if (error == ApiValidationError.phoneNumberAlreadyExists) {\n        print('Phone number already exists.');\n      }\n    },\n    orElse: () =\u003e print('Something went wrong.'),\n  );\n\n  // `match`\n  if (networkError.match((error) =\u003e error.isEmailAlreadyExists)) {\n    print('Email already exists');\n  }\n\n  // `cast`\n  final signUpError = networkError.cast(SignUpError.fromApiError);\n\n  // `name`\n  print(signUpError.name);\n}\n\nenum ApiValidationError {\n  emailAlreadyExists,\n  phoneNumberAlreadyExists;\n\n  bool get isEmailAlreadyExists =\u003e this == emailAlreadyExists;\n\n  bool get isPhoneNumberAlreadyExists =\u003e this == phoneNumberAlreadyExists;\n}\n\nenum SignUpError {\n  emailAlreadyExists,\n  phoneNumberAlreadyExists,\n  otherValidationError;\n\n  factory SignUpError.fromApiError(ApiValidationError error) {\n    if (error.isEmailAlreadyExists) {\n      return SignUpError.emailAlreadyExists;\n    } else if (error.isPhoneNumberAlreadyExists) {\n      return SignUpError.phoneNumberAlreadyExists;\n    } else {\n      return SignUpError.otherValidationError;\n    }\n  }\n}\n\n```\n---\n\nYou can use it with any HTTP client library. For example, [here](https://gist.github.com/elias8/2d5c44e1337178e2efa37210534272b5), you can find an extension to the [Dio](https://pub.dev/packages/dio) library, so you don't have to write it from scratch. Or you can see an example project [here](https://github.com/elias8/last_fm) for more detail and usage.\n\n## Maintainers\n\n- [Elias Andualem](https://github.com/elias8)\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felias8%2Fnetworkx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felias8%2Fnetworkx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felias8%2Fnetworkx/lists"}