-
Notifications
You must be signed in to change notification settings - Fork 4
/
opensource-utils.el
55 lines (42 loc) · 1.95 KB
/
opensource-utils.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
;;; opensource-utils.el --- some tools
;; Copyright (C) 2016 Nicolas Lamirault <nicolas.lamirault@gmail.com>
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;; http://www.apache.org/licenses/LICENSE-2.0
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;; Commentary:
;;; Code:
(require 'dash)
(require 's)
;; Errors
(eval-and-compile
(unless (fboundp 'define-error)
;; Shamelessly copied from Emacs trunk :)
(defun define-error (name message &optional parent)
"Define NAME as a new error signal.
MESSAGE is a string that will be output to the echo area if such an error
is signaled without being caught by a `condition-case'.
PARENT is either a signal or a list of signals from which it inherits.
Defaults to `error'."
(unless parent (setq parent 'error))
(let ((conditions
(if (consp parent)
(apply #'nconc
(mapcar (lambda (parent)
(cons parent
(or (get parent 'error-conditions)
(error "Unknown signal `%s'" parent))))
parent))
(cons parent (get parent 'error-conditions)))))
(put name 'error-conditions
(delete-dups (copy-sequence (cons name conditions))))
(when message (put name 'error-message message))))))
(define-error 'opensource-error "Opensource error")
(define-error 'opensource-http-error "HTTP Error" 'opensource-error)
(provide 'opensource-utils)
;;; opensource-utils.el ends here