{"record":{"id":"8f7dec4d61673cc9","repo":"jfeinstein10/SlidingMenu","slug":"slidingmenu-mode-must-be-left-right-or-left-righ","errorCode":null,"errorMessage":"SlidingMenu mode must be LEFT, RIGHT, or LEFT_RIGHT","messagePattern":"SlidingMenu mode must be LEFT, RIGHT, or LEFT_RIGHT","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java","lineNumber":448,"sourceCode":"\t\tmViewAbove.setSlidingEnabled(b);\n\t}\n\n\t/**\n\t * Checks if is sliding enabled.\n\t *\n\t * @return true, if is sliding enabled\n\t */\n\tpublic boolean isSlidingEnabled() {\n\t\treturn mViewAbove.isSlidingEnabled();\n\t}\n\n\t/**\n\t * Sets which side the SlidingMenu should appear on.\n\t * @param mode must be either SlidingMenu.LEFT or SlidingMenu.RIGHT\n\t */\n\tpublic void setMode(int mode) {\n\t\tif (mode != LEFT && mode != RIGHT && mode != LEFT_RIGHT) {\n\t\t\tthrow new IllegalStateException(\"SlidingMenu mode must be LEFT, RIGHT, or LEFT_RIGHT\");\n\t\t}\n\t\tmViewBehind.setMode(mode);\n\t}\n\n\t/**\n\t * Returns the current side that the SlidingMenu is on.\n\t * @return the current mode, either SlidingMenu.LEFT or SlidingMenu.RIGHT\n\t */\n\tpublic int getMode() {\n\t\treturn mViewBehind.getMode();\n\t}\n\n\t/**\n\t * Sets whether or not the SlidingMenu is in static mode (i.e. nothing is moving and everything is showing)\n\t *\n\t * @param b true to set static mode, false to disable static mode.\n\t */\n\tpublic void setStatic(boolean b) {","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/jfeinstein10/SlidingMenu/blob/4254feca3ece9397cd501921ee733f19ea0fdad8/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java#L430-L466","documentation":"An IllegalStateException guard thrown by SlidingMenu.setMode(int) when the supplied mode integer is not one of the three supported constants (SlidingMenu.LEFT, SlidingMenu.RIGHT, SlidingMenu.LEFT_RIGHT). It is a generic sentinel validation: the input at fault is the raw mode value passed to setMode, typically a mistyped constant, an arbitrary int, or a value read from unvalidated configuration or from onCheckedChanged handlers wiring the wrong checkbox/radio values. Callers must pass exactly one of the declared constants.","triggerScenarios":"Calling setMode() with an arbitrary int, a constant from another class (e.g. Gravity.LEFT), or a computed value.","commonSituations":"Passing android.view.Gravity values instead of SlidingMenu constants; passing TOUCHMODE constants; saving/restoring mode as an int that was corrupted.","solutions":["Use only SlidingMenu.LEFT, SlidingMenu.RIGHT, or SlidingMenu.LEFT_RIGHT","Replace gravity/other constants with the SlidingMenu constants","Wrap in try-catch or validate the mode int before calling"],"exampleFix":"// before\nslidingMenu.setMode(Gravity.START);\n// after\nslidingMenu.setMode(SlidingMenu.LEFT);","handlingStrategy":"validation","validationCode":"if (mode != SlidingMenu.LEFT && mode != SlidingMenu.RIGHT && mode != SlidingMenu.LEFT_RIGHT) throw new IllegalArgumentException(\"invalid mode: \" + mode);\nslidingMenu.setMode(mode);","typeGuard":null,"tryCatchPattern":"try { slidingMenu.setMode(mode); } catch (IllegalStateException e) { slidingMenu.setMode(SlidingMenu.LEFT); }","preventionTips":["Only use SlidingMenu mode constants","Never persist raw ints without validating on restore","Do not confuse Gravity constants with SlidingMenu modes"],"tags":["android","slidingmenu","enum-argument","illegal-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"4254feca3ece9397cd501921ee733f19ea0fdad8","analyzedAt":"2026-09-09T10:08:27.041Z","contentChangedAt":"2026-09-09T10:08:27.041Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}