RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Cursor rules/WisdmLabs/moodle-local_edwiserreports-free

Cursor rule

.cursor/rules/moodle-error-handling.mdc

[object Object]

Cursor rules

Quality

50/100

Scores the file, not the repository.

Length

343 words

5 headings · 1 code blocks

Repository

4

— · pushed 2 days ago

Last changed

3 days ago

First indexed 3 days ago.
WisdmLabs/moodle-local_edwiserreports-free/.cursor/rules/moodle-error-handling.mdcRawGitHub
1---
2description:
3globs:
4alwaysApply: false
5---
6# Moodle Error Handling
7 
8## Purpose
9Ensure consistent and proper error handling across all Moodle PHP code for better debugging and user experience.
10 
11## Instructions
12When implementing error handling in Moodle PHP code, follow these practices:
13 
141. **Use Moodle Exceptions**: Use `moodle_exception` and specific exception types
152. **Parameter Validation**: Use `required_param()`, `optional_param()` with proper validation
163. **Debugging**: Use `debugging()` for development, `error_log()` for critical errors
174. **User Feedback**: Provide meaningful error messages using language strings
185. **Graceful Degradation**: Handle errors gracefully without breaking the user experience
196. **Logging**: Use Moodle's logging system for important events and errors
207. **Context Information**: Include relevant context in error messages
218. **Error Recovery**: Implement recovery mechanisms where possible
22 
23## Examples
24 
25```php
26<?php
27// File: ./includes/error_handling_example.php
28 
29/**
30 * Example of proper error handling in Moodle
31 */
32function process_user_action($userid, $action) {
33 global $DB, $USER;
34
35 try {
36 // Parameter validation
37 $userid = required_param('userid', PARAM_INT);
38 $action = required_param('action', PARAM_ALPHA);
39
40 // Validate user exists
41 $user = $DB->get_record('user', ['id' => $userid], '*', MUST_EXIST);
42
43 // Check permissions
44 if (!has_capability('moodle/user:edit', context_user::instance($userid))) {
45 throw new moodle_exception('nopermission', 'core');
46 }
47
48 // Perform action with error handling
49 switch ($action) {
50 case 'update':
51 $result = update_user_profile($userid);
52 break;
53 case 'delete':
54 $result = delete_user_data($userid);
55 break;
56 default:
57 throw new moodle_exception('invalidaction', 'core');
58 }
59
60 // Log successful action
61 \core\event\user_action_performed::create([
62 'objectid' => $userid,
63 'relateduserid' => $USER->id,
64 'other' => ['action' => $action]
65 ])->trigger();
66
67 return $result;
68
69 } catch (dml_exception $e) {
70 // Database errors
71 debugging('Database error: ' . $e->getMessage(), DEBUG_DEVELOPER);
72 throw new moodle_exception('databaseerror', 'core');
73
74 } catch (moodle_exception $e) {
75 // Re-throw Moodle exceptions
76 throw $e;
77
78 } catch (Exception $e) {
79 // Unexpected errors
80 error_log('Unexpected error in process_user_action: ' . $e->getMessage());
81 throw new moodle_exception('unknownerror', 'core');
82 }
83}
84 
85/**
86 * Graceful error handling with user feedback
87 */
88function display_user_data($userid) {
89 try {
90 $userdata = get_user_data($userid);
91 echo format_string($userdata->name);
92
93 } catch (moodle_exception $e) {
94 // Show user-friendly error
95 echo html_writer::div(
96 get_string('error_loading_user', 'core'),
97 'alert alert-warning'
98 );
99
100 // Log detailed error for administrators
101 debugging('Error loading user data: ' . $e->getMessage(), DEBUG_DEVELOPER);
102 }
103}
104```
105 
106## Exceptions
107- Critical system errors may require different handling approaches
108- Third-party integrations may have specific error handling requirements
109 

Sections

  • Moodle Error Handling
  • Purpose
  • Instructions
  • Examples
  • Exceptions

What it covers

agent-behaviour

Stack — with the evidence

javascript

(1.00)

Glob targeting

  • [object Object]

Format

Cursor rules

The most expressive format here. Many small .mdc files, each with frontmatter declaring when it should load, so a rule about migrations only enters context when a migration is open. Costs the most to maintain and only one editor reads it.

What the corpus says about it

Repository

Owner
WisdmLabs
Language
—
License
—
Archived
no

All configs in this repo

Also in WisdmLabs/moodle-local_edwiserreports-free

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-ajax-and-js-integration.mdc · 4Cursor rulesjavascriptagent-behaviour50/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-configuration-management.mdc · 4Cursor rulesjavascriptagent-behaviour36/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-database-patterns.mdc · 4Cursor rulesjavascriptstyledatabaseagent-behaviour54/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-events-and-callbacks.mdc · 4Cursor rulesjavascriptagent-behaviour50/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-file-and-media-handling.mdc · 4Cursor rulesjavascriptagent-behaviour36/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-internationalization.mdc · 4Cursor rulesjavascriptagent-behaviour36/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-performance-optimization.mdc · 4Cursor rulesjavascriptperformanceagent-behaviour50/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-php-coding-standards.mdc · 4Cursor rulesjavascriptagent-behaviour50/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-plugin-structure.mdc · 4Cursor rulesjavascriptarchagent-behaviour54/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-scheduled-tasks.mdc · 4Cursor rulesjavascriptagent-behaviour50/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-security-practices.mdc · 4Cursor rulesjavascriptsecurityagent-behaviour50/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-testing-and-quality.mdc · 4Cursor rulesjavascripttesttesting-strategyagent-behaviour54/1003 days ago
WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-web-services-and-api.mdc · 4Cursor rulesjavascriptapiagent-behaviour50/1003 days ago
Diff against .cursor/rules/moodle-ajax-and-js-integration.mdc Diff against .cursor/rules/moodle-configuration-management.mdc Diff against .cursor/rules/moodle-database-patterns.mdc Diff against .cursor/rules/moodle-events-and-callbacks.mdc Diff against .cursor/rules/moodle-file-and-media-handling.mdc Diff against .cursor/rules/moodle-internationalization.mdc Diff against .cursor/rules/moodle-performance-optimization.mdc Diff against .cursor/rules/moodle-php-coding-standards.mdc Diff against .cursor/rules/moodle-plugin-structure.mdc Diff against .cursor/rules/moodle-scheduled-tasks.mdc Diff against .cursor/rules/moodle-security-practices.mdc Diff against .cursor/rules/moodle-testing-and-quality.mdc Diff against .cursor/rules/moodle-web-services-and-api.mdc

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126Cursor rulesgobun+5setupbuildtestlint-format+6100/1003 days ago
TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45Cursor rulestypescriptpytest+15testlint-formatstylearch+5100/1003 days ago
markstev/mark-starter.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+14setuptestlint-formatstyle+699/1003 days ago
Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+13setuptestlint-formatstyle+799/1003 days ago
deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1Cursor rulestypescriptnextjs+5setuptestlint-formatstyle+799/1003 days ago
dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+15setuptestlint-formatstyle+799/1003 days ago
langflow-ai/langflow.cursor/rules/docs_development.mdc · 153kCursor rulespythonnode+16setupbuildtestlint-format+797/1003 days ago
TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45Cursor rulestypescriptpytest+15teststyletesting-strategysecurity+397/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack