{"record":{"id":"e0f3af572bf290a1","repo":"material-components/material-components-android","slug":"email-d-does-not-exist","errorCode":null,"errorMessage":"Email %d does not exist.","messagePattern":"Email (.+?) does not exist\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"catalog/java/io/material/catalog/adaptive/AdaptiveListViewDemoFragment.java","lineNumber":251,"sourceCode":"        Arrays.asList(\n            new Email(0L, true),\n            new Email(1L, false),\n            new Email(2L, false),\n            new Email(3L, false),\n            new Email(4L, false),\n            new Email(5L, false),\n            new Email(6L, false),\n            new Email(7L, false),\n            new Email(8L, false),\n            new Email(9L, false));\n\n    static Email getEmailById(long emailId) {\n      for (Email email : emailData) {\n        if (email.id == emailId) {\n          return email;\n        }\n      }\n      throw new IllegalArgumentException(\n          String.format(Locale.US, \"Email %d does not exist.\", emailId));\n    }\n\n    /** Class that represents an email. */\n    static class Email {\n      private final long id;\n      private boolean isSelected;\n\n      Email(long id, boolean isSelected) {\n        this.id = id;\n        this.isSelected = isSelected;\n      }\n\n      /** Returns the email id. */\n      public long getEmailId() {\n        return id;\n      }\n","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/catalog/java/io/material/catalog/adaptive/AdaptiveListViewDemoFragment.java#L233-L269","documentation":"Thrown by the static lookup helper getEmailById(long) in the catalog's AdaptiveListViewDemoFragment. It iterates the hardcoded emailData list (Email objects with ids 1..9) and throws IllegalArgumentException when no Email matches the requested id. This is demo/sample data code, not library API.","triggerScenarios":"Calling AdaptiveListViewDemoFragment.getEmailById(emailId) with an id that is not one of the ids present in the static emailData list (e.g. 0, negative values, or ids >= 10).","commonSituations":"Copy-pasting this catalog demo into your own app and passing ids from your real data model that do not match the sample range; off-by-one loops; passing an unset long (0) or a default id before data initialization.","solutions":["Pass an id that exists in emailData — the demo defines Email objects with ids 1 through 9.","If you adapted this demo, replace emailData with your own dataset and keep ids in sync with what you pass to getEmailById.","Guard the call: check the id range (1..emailData.size()) before invoking getEmailById.","Wrap the call in try/catch (IllegalArgumentException) only if a missing email is an expected, recoverable condition in your flow."],"exampleFix":"// before\nEmail email = AdaptiveListViewDemoFragment.getEmailById(42); // throws\n\n// after\nEmail email = AdaptiveListViewDemoFragment.getEmailById(5); // id exists in emailData","handlingStrategy":"validation","validationCode":"boolean emailExists = emailId >= 1 && emailId <= 9; // ids defined in emailData\nif (emailExists) {\n  Email email = AdaptiveListViewDemoFragment.getEmailById(emailId);\n}","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) only at the boundary where a user-supplied id enters the demo flow; treat it as 'not found' and skip/degrade, never swallow silently.","preventionTips":["Keep request ids sourced from the same dataset you look them up in.","In adapted demo code, replace sample data wholesale rather than mixing real ids with sample ids."],"tags":["catalog-demo","sample-data","illegal-argument","lookup"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}