Commits

seanmcl committed 871bb23

error handling, improved interface (issue #140)

Comments (0)

Files changed (1)

elisp/omake/omake-errors.el

+
+(put 'Omake.Errors.tramp 'error-conditions '(error Omake.Errors.all Omake.Errors.tramp))
+(put 'Omake.Errors.tramp 'error-message "Omake mode does not support remote files")
+
+(put 'Omake.Errors.abort 'error-conditions '(error Omake.Errors.all Omake.Errors.abort))
+(put 'Omake.Errors.abort 'error-message "Aborted")
+
+(defmacro Omake.handle-errors (&rest body)
+  "Handle omake-mode errors"
+  (declare (indent defun))
+  (declare (debug (body)))
+  `(condition-case err
+       (progn ,@body)
+     (Omake.Errors.all (message "%s" (error-message-string err)))))
+;; (Omake.handle-errors (signal 'Omake.Errors.tramp '(1 2 3)))
+;; (defun foo (&optional x) (interactive) (Omake.handle-errors (let* ((x (if x x 5))) (message "%d" x))))
+;; (macroexpand '(Omake.handle-errors (signal 'Omake.Errors.tramp '(1 2 3))))
+
+(font-lock-add-keywords
+ 'emacs-lisp-mode
+ '(("\\<\\(Omake.handle-errors\\)" 1 font-lock-keyword-face))
+ t)
+
+
+;; (setq command-error-function nil)
+;; (setq command-error-function
+;;       (lambda (data context caller)
+;;         (message "in command-error-function")))
+
+;; (signal 'Omake.Errors.tramp '(1 2 3))
+;; (error "abc")
+
+(provide 'omake-errors)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.