Результаты поиска
Гайсы что означает runtime error на acmp
RUNTIME ERROR
1222   1   17:02, 13th August, 2020
Использование свойства объекта по умолчанию для свойства метода
Я пытаюсь сделать это (что приводит к неожиданной ошибке T_VARIABLE):
public function createShipment($startZip, $endZip, $weight = $this->getDefaultWeight()){}
Я не хочу помещать магическое число туда для веса, так как объект, который я использую, имеет параметр "defaultWeight" , который получают все новые поставки, если вы не укажете вес. Я не могу поместить defaultWeight в саму отгрузку, потому что она изменяется от группы отгрузки к группе отгрузки. Есть ли лучший способ сделать это, чем следующий?
public function createShipment($startZip, $endZip, weight = 0){
if($weight <= 0){
$weight = $this->getDefaultWeight();
}
}
Уменьшение количества повторяющихся кодов обработки ошибок в C#?
Я никогда не был полностью доволен тем, как работает обработка исключений, есть много исключений и try / catch приносит в таблицу (размотка стека и т. д.), но, похоже, в этом процессе нарушается большая часть модели OO.
В любом случае, вот в чем проблема:
Допустим, у вас есть какой-то класс, который обертывает или включает сетевые операции с файлом IO (например, чтение и запись в какой-то файл по какому-то конкретному пути UNC). По разным причинам вы не хотите, чтобы эти операции IO завершились неудачей, поэтому, если вы обнаружите, что они завершились неудачей, вы повторяете их и продолжаете повторять, пока они не завершатся успешно или вы не достигнете тайм-аута. У меня уже есть удобный класс RetryTimer, который я могу создать и использовать, чтобы перевести текущий поток в спящий режим между повторными попытками и определить, когда истек период ожидания и т. д.
Проблема в том, что у вас есть куча операций IO в нескольких методах этого класса, и вам нужно обернуть каждую из них в логику try-catch / retry.
Вот пример фрагмента кода:
RetryTimer fileIORetryTimer = new RetryTimer(TimeSpan.FromHours(10));
bool success = false;
while (!success)
{
try
{
// do some file IO which may succeed or fail
success = true;
}
catch (IOException e)
{
if (fileIORetryTimer.HasExceededRetryTimeout)
{
throw e;
}
fileIORetryTimer.SleepUntilNextRetry();
}
}
Итак, как избежать дублирования большей части этого кода для каждой операции file IO в классе? Мое решение состояло в использовании анонимных блоков делегатов и единственного метода в классе, который выполнял переданный ему блок делегатов. Это позволило мне делать подобные вещи другими методами:
this.RetryFileIO( delegate()
{
// some code block
} );
Мне это несколько нравится, но оставляет желать лучшего. Я бы хотел услышать, как другие люди решают подобные проблемы.
Глобальная обработка исключений для элемента управления winforms
При работе над ASP.NET 1.1 проектами я всегда использовал Global.asax, чтобы поймать все ошибки. Я ищу аналогичный способ поймать все исключения в пользовательском элементе управления Windows Forms, который в конечном итоге является размещенным элементом управления IE. Каков правильный способ сделать что-то подобное?
Как вы регистрируете ошибки (исключения) в ваших приложениях ASP.NET?
Я ищу лучший способ регистрации ошибок в приложении ASP.NET. Я хочу иметь возможность получать электронные письма, когда в моем приложении возникают ошибки, с подробной информацией об исключении и текущем запросе.
В моей компании мы привыкли иметь свой собственный ErrorMailer, ловя все в Global.asax Application_Error. Он был "Ok", но не очень гибким и настраиваемым.
Мы недавно переключились на NLog. Это гораздо более настраиваемо, мы можем определить различные цели для ошибок, фильтровать их, буферизировать их (еще не пробовали). Это очень хорошее улучшение.
Но недавно я обнаружил, что для этой цели в фреймворке .Net есть целое пространство имен : System.Web.Management , и его можно настроить в разделе healthMonitoring web.config.
Вы когда-нибудь работали с мониторингом здоровья .Net? Каково ваше решение для регистрации ошибок?
Есть ли способ обработки ошибок из объектов COM в RDML?
Есть ли способ обработки ошибок из объектов COM в RDML? Например, при вызове методов Word VBA, таких как PasteSpecial, возвращается ошибка и приложение LANSA завершает работу. Я не могу найти ничего в документации, чтобы разрешить обработку этих ошибок.
На самом деле, обработка ошибок вообще является слабым местом для LANSA и RDML, но это другая тема.
Как лучше всего сообщать об ошибках из рабочего процесса SharePoint?
У меня есть пользовательское действие в рабочем процессе, и я хотел бы сообщить об ошибке пользователю, когда что-то пойдет не так. Как лучше всего это сделать?
UPD: в идеале я хотел бы поместить рабочий процесс в состояние ошибки и записать сообщение в журнал рабочего процесса. Это кажется невозможным. Как можно ближе подобраться к нему? Я хочу, чтобы повторно используемый раствор,то, что легко для пользователей, чтобы настроить, когда через мои пользовательские действия в SharePoint дизайнер.
Добавил больше деталей к вопросу.
@mauro это заботится о сохранении ошибки, но как я могу отобразить ошибку пользователю таким образом, чтобы это имело смысл?
@AdamSane это кажется довольно хрупким решением. Это не вопрос настройки этого один раз на одном сайте. Мне нужно что-то, что другие могут добавить, используя SPD.
Как я могу регистрировать необнаруженные исключения в PHP?
Я выяснил, как преобразовать ошибки в исключения, и я хорошо отображаю их, если они не пойманы, но я не знаю, как их правильно регистрировать. Просто записать их в файл не будет полезно, не так ли? И вы бы рискнули получить доступ к базе данных, когда вы еще не знаете, что вызвало исключение?
Группа SQL с заказа
У меня есть таблица тегов, и я хочу получить самый высокий счетчик тегов из списка.
Примерные данные выглядят следующим образом
id (1) tag ('night')
id (2) tag ('awesome')
id (3) tag ('night')
с помощью
SELECT COUNT(*), `Tag` from `images-tags`
GROUP BY `Tag`
возвращает мне данные, которые я ищу совершенно. Однако я хотел бы организовать его так, чтобы самые высокие значения тегов были первыми, и ограничить его отправкой мне только первых 20 или около того.
Я попробовал это сделать...
SELECT COUNT(id), `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY COUNT(id) DESC
LIMIT 20
и я продолжаю получать "Invalid use of group function - ErrNr 1111"
Что я делаю не так?
Я использую MySQL 4.1.25-Debian
Как поймать SQLServer тайм-аут исключения
Мне нужно специально поймать SQL исключений таймаута сервера, чтобы их можно было обрабатывать по-разному. Я знаю, что могу поймать SqlException, а затем проверить, содержит ли строка сообщения "Timeout", но мне было интересно, есть ли лучший способ сделать это?
try
{
//some code
}
catch (SqlException ex)
{
if (ex.Message.Contains("Timeout"))
{
//handle timeout
}
else
{
throw;
}
}
Почему не запускается программа? Python + TKINTER
import os
from tkinter import *
import subprocess
from tkinter import ttk
path = "C:/Program Files/Organaizer"
m1 = "C:/Program Files/Organaizer/Monday/Registration"
m2 = "C:/Program Files/Organaizer/Monday/Literature"
m3 = "C:/Program Files/Organaizer/Monday/ITGS"
m4 = "C:/Program Files/Organaizer/Monday/Maths"
t1 = "C:/Program Files/Organaizer/Tuesday/Registration"
t2 = "C:/Program Files/Organaizer/Tuesday/English"
t3 = "C:/Program Files/Organaizer/Tuesday/Literature"
t4 = "C:/Program Files/Organaizer/Tuesday/CS"
t5 = "C:/Program Files/Organaizer/Tuesday/PE"
w1 = "C:/Program Files/Organaizer/Wednesday/Registration"
w2 = "C:/Program Files/Organaizer/Wednesday/CS"
w3 = "C:/Program Files/Organaizer/Wednesday/Psychology"
w4 = "C:/Program Files/Organaizer/Wednesday/English"
h1 = "C:/Program Files/Organaizer/Thursday/Registration"
h2 = "C:/Program Files/Organaizer/Thursday/English"
h3 = "C:/Program Files/Organaizer/Thursday/Maths"
h4 = "C:/Program Files/Organaizer/Thursday/Literature"
h5 = "C:/Program Files/Organaizer/Thursday/ITGS"
f1 = "C:/Program Files/Organaizer/Friday/Registration"
f2 = "C:/Program Files/Organaizer/Friday/CS"
f3 = "C:/Program Files/Organaizer/Friday/Psychology"
f4 = "C:/Program Files/Organaizer/Friday/Grorootg Minds"
try:
os.makedirs(path)
except OSError:
print ("The %s directory could not be created" % path)
else:
print ("The %s directory was successfully created" % path)
try:
os.makedirs(m1)
except OSError:
print ("The %s directory could not be created" % m1)
else:
print ("The %s directory was successfully created" % m1)
try:
os.makedirs(m2)
except OSError:
print ("The %s directory could not be created" % m2)
else:
print ("The %s directory was successfully created" % m2)
try:
os.makedirs(m3)
except OSError:
print ("The %s directory could not be created" % m3)
else:
print ("The %s directory was successfully created" % m3)
try:
os.makedirs(m4)
except OSError:
print ("The %s directory could not be created" % m4)
else:
print ("The %s directory was successfully created" % m4)
try:
os.makedirs(t1)
except OSError:
print ("The %s directory could not be created" % t1)
else:
print ("The %s directory was successfully created" % t1)
try:
os.makedirs(t2)
except OSError:
print ("The %s directory could not be created" % t2)
else:
print ("The %s directory was successfully created" % t2)
try:
os.makedirs(t3)
except OSError:
print ("The %s directory could not be created" % t3)
else:
print ("The %s directory was successfully created" % t3)
try:
os.makedirs(t4)
except OSError:
print ("The %s directory could not be created" % t4)
else:
print ("The %s directory was successfully created" % t4)
try:
os.makedirs(t5)
except OSError:
print ("The %s directory could not be created" % t5)
else:
print ("The %s directory was successfully created" % t5)
try:
os.makedirs(w1)
except OSError:
print ("The %s directory could not be created" % w1)
else:
print ("The %s directory was successfully created" % w1)
try:
os.makedirs(w2)
except OSError:
print ("The %s directory could not be created" % w2)
else:
print ("The %s directory was successfully created" % w2)
try:
os.makedirs(w3)
except OSError:
print ("The %s directory could not be created" % w3)
else:
print ("The %s directory was successfully created" % w3)
try:
os.makedirs(w4)
except OSError:
print ("The %s directory could not be created" % w4)
else:
print ("The %s directory was successfully created" % w4)
try:
os.makedirs(h1)
except OSError:
print ("The %s directory could not be created" % h1)
else:
print ("The %s directory was successfully created" % h1)
try:
os.makedirs(h2)
except OSError:
print ("The %s directory could not be created" % h2)
else:
print ("The %s directory was successfully created" % h2)
try:
os.makedirs(h3)
except OSError:
print ("The %s directory could not be created" % h3)
else:
print ("The %s directory was successfully created" % h3)
try:
os.makedirs(h4)
except OSError:
print ("The %s directory could not be created" % h4)
else:
print ("The %s directory was successfully created" % h4)
try:
os.makedirs(h5)
except OSError:
print ("The %s directory could not be created" % h5)
else:
print ("The %s directory was successfully created" % h5)
try:
os.makedirs(f1)
except OSError:
print ("The %s directory could not be created" % f1)
else:
print ("The %s directory was successfully created" % f1)
try:
os.makedirs(f2)
except OSError:
print ("The %s directory could not be created" % f2)
else:
print ("The %s directory was successfully created" % f2)
try:
os.makedirs(f3)
except OSError:
print ("The %s directory could not be created" % f3)
else:
print ("The %s directory was successfully created" % f3)
try:
os.makedirs(f4)
except OSError:
print ("The %s directory could not be created" % f4)
else:
print ("The %s directory was successfully created" % f4)
root = Tk()
root.title("Login")
root.resizable(0, 0)
root.configure(bg='black')
root.geometry("910x740")
attempts=0
correctpassword="1234"
entrypass = Entry(root, width=25, textvariable=password, show="*")
entrypass.pack()
def start():
while attempts<3:
if entrypass==correctpassword:
print('Correct.')
altroot = Toplevel(root)
altroot.title("Organaizer")
altroot.resizable(0, 0)
altroot.configure(bg='black')
altroot.geometry('910x740')
def monviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Monday\Registration"')
def tuviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Tuesday\Registration"')
def wedviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Wednesday\Registration"')
def huviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Thursday\Registration"')
def frviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Friday\Registration"')
def mondays():
monles = Toplevel(root)
monles.title("MONDAY")
monles.resizable(0, 0)
monles.configure(bg='black')
monles.geometry('910x740')
monlesson = Frame(monles, width=750, height=600, bg='black')
monlesson.grid(row=0, column=0, padx=1, pady=1)
monregistration = Label(monlesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=6)
monregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
monliterature = Label(monlesson, text="Russian Literature || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=6)
monliterature.grid(row=1, column=0, sticky=S, padx=1, pady=1)
monitgs = Label(monlesson, text="ITGS || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=6)
monitgs.grid(row=2, column=0, sticky=S, padx=1, pady=1)
monmaths = Label(monlesson, text="Maths || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=6)
monmaths.grid(row=3, column=0, sticky=S, padx=1, pady=1)
monview = Button(monlesson, text="View", fg='black', bg='white', font=300, width=85, height=6, command=monviewcom)
monview.grid(row=4, column=0, sticky=S, padx=1, pady=1)
def tuesdays():
tules = Toplevel(root)
tules.title("TUESDAY")
tules.resizable(0, 0)
tules.configure(bg='black')
tules.geometry('910x740')
tulesson = Frame(tules, width=750, height=600, bg='black')
tulesson.grid(row=0, column=0, padx=1, pady=1)
turegistration = Label(tulesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=5)
turegistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
tuenglish = Label(tulesson, text="English || 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=5)
tuenglish.grid(row=1, column=0, sticky=S, padx=1, pady=1)
tuliterature = Label(tulesson, text="Literature || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=5)
tuliterature.grid(row=2, column=0, sticky=S, padx=1, pady=1)
tucs = Label(tulesson, text="CS || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=5)
tucs.grid(row=3, column=0, sticky=S, padx=1, pady=1)
tupe = Label(tulesson, text="PE || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=5)
tupe.grid(row=4, column=0, sticky=S, padx=1, pady=1)
tuview = Button(tulesson, text="View", fg='black', bg='white', font=300, width=85, height=5, command=tuviewcom)
tuview.grid(row=5, column=0, sticky=S, padx=1, pady=1)
def wednesdays():
wedles = Toplevel(root)
wedles.title("WEDNESDAY")
wedles.resizable(0, 0)
wedles.configure(bg='black')
wedles.geometry('910x740')
wedlesson = Frame(wedles, width=750, height=600, bg='black')
wedlesson.grid(row=0, column=0, padx=1, pady=1)
wedregistration = Label(wedlesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=6)
wedregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
wedliterature = Label(wedlesson, text="CS || 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=6)
wedliterature.grid(row=1, column=0, sticky=S, padx=1, pady=1)
weditgs = Label(wedlesson, text="Psychology || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=6)
weditgs.grid(row=2, column=0, sticky=S, padx=1, pady=1)
wedmaths = Label(wedlesson, text="English || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=6)
wedmaths.grid(row=3, column=0, sticky=S, padx=1, pady=1)
wedview = Button(wedlesson, text="View", fg='black', bg='white', font=300, width=85, height=6, command=wedviewcom)
wedview.grid(row=4, column=0, sticky=S, padx=1, pady=1)
def thursdays():
hules = Toplevel(root)
hules.title("THURSDAY")
hules.resizable(0, 0)
hules.configure(bg='black')
hules.geometry('910x740')
hulesson = Frame(hules, width=750, height=600, bg='black')
hulesson.grid(row=0, column=0, padx=1, pady=1)
huregistration = Label(hulesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=5)
huregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
huenglish = Label(hulesson, text="English || 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=5)
huenglish.grid(row=1, column=0, sticky=S, padx=1, pady=1)
humaths = Label(hulesson, text="Maths || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=5)
humaths.grid(row=2, column=0, sticky=S, padx=1, pady=1)
huliterature = Label(hulesson, text="Literature || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=5)
huliterature.grid(row=3, column=0, sticky=S, padx=1, pady=1)
huitgs = Label(hulesson, text="ITGS || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=5)
huitgs.grid(row=4, column=0, sticky=S, padx=1, pady=1)
huview = Button(hulesson, text="View", fg='black', bg='white', font=300, width=85, height=5, command=huviewcom)
huview.grid(row=5, column=0, sticky=S, padx=1, pady=1)
def fridays():
frles = Toplevel(root)
frles.title("FRIDAY")
frles.resizable(0, 0)
frles.configure(bg='black')
frles.geometry('910x740')
frlesson = Frame(frles, width=750, height=600, bg='black')
frlesson.grid(row=0, column=0, padx=1, pady=1)
frregistration = Label(frlesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=6)
frregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
frcs = Label(frlesson, text="CS|| 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=6)
frcs.grid(row=1, column=0, sticky=S, padx=1, pady=1)
frpsychology = Label(frlesson, text="Psychology || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=6)
frpsychology.grid(row=2, column=0, sticky=S, padx=1, pady=1)
frgm = Label(frlesson, text="GM || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=6)
frgm.grid(row=3, column=0, sticky=S, padx=1, pady=1)
frview = Button(frlesson, text="View", fg='black', bg='white', font=300, width=85, height=6, command=frviewcom)
frview.grid(row=4, column=0, sticky=S, padx=1, pady=1)
lu = Frame(altroot, width=250, height=200, bg='white')
lu.grid(row=0, column=0, padx=1, pady=1, sticky=N)
tp = Frame(altroot, width=250, height=200, bg='white')
tp.grid(row=0, column=1, padx=1, pady=1, sticky=N)
ru = Frame(altroot, width=250, height=200, bg='white')
ru.grid(row=0, column=2, padx=1, pady=1, sticky=N)
lt = Frame(altroot, width=250, height=200, bg='white')
lt.grid(row=1, column=0, padx=1, pady=1, sticky=N)
md = Frame(altroot, width=250, height=200, bg='white')
md.grid(row=1, column=1, padx=1, pady=1, sticky=N)
rt = Frame(altroot, width=250, height=200, bg='white')
rt.grid(row=1, column=2, padx=1, pady=1, sticky=N)
bt = Frame(altroot, width=250, height=200, bg='white')
bt.grid(row=2, column=1, padx=1, pady=1, sticky=N)
mday = Button(lu, text="MONDAY", fg='black', bg='white', font=150, width=27, height=10, command=mondays)
mday.pack()
tday = Button(tp, text="TUESDAY", fg='black', bg='white', font=150, width=27, height=10, command=tuesdays)
tday.pack()
wday = Button(ru, text="WEDNESDAY", fg='black', bg='white', font=150, width=27, height=10, command=wednesdays)
wday.pack()
thday = Button(lt, text="THURSDAY", fg='black', bg='white', font=150, width=27, height=10, command=thursdays)
thday.pack()
fday = Button(md, text="FRIDAY", fg='black', bg='white', font=150, width=27, height=10, command=fridays)
fday.pack()
saday = Label(rt, text="SATURDAY", fg='black', bg='white', font=150, width=27, height=10)
saday.pack()
sday = Label(bt, text="SUNDAY", fg='black', bg='white', font=150, width=27, height=10)
sday.pack()
altroot.mainloop()
else:
attempts+=1
print('incorrect!')
if attempts==3:
print('too many attempts')
ttt = Button(root, text="Enter", command=start).pack()
root.mainloop()